ubuntu18安装mysql 时没有设置root密码,可能没有输入密码或者忘记输入密码
首先使用service mysql status查看MySQL是否处于启动状态
使用vim命令输入MySQL默认的用户名和用户密码:sudo vim /etc/mysql/debian.cnf
使用该用户名和密码登录:mysql -udebian-sys-maint -pIFzE9j3WJWE27p6I
update mysql.user set authentication_string=’root’ where user=’root’and Host = ‘localhost’;
flush privileges;
GRANT ALL PRIVILEGES ON . TO ‘root’@’localhost’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;
flush privileges;