解决安装MySQL 5.6 启动mysql提示 ERROR 1045 (28000): Access denied for user root@ localhost的异常

在UBUNTU16.04上安装mysql5.6后,启动mysql,

错误提示: ERROR 1045 (28000): Access denied for user root@ localhost

这里需要重新配置数据库密钥,流程如下:

1. sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

2. 在该配置文件最后一行插入:skip-grant-tables

3. 重启mysql服务sudo service mysql restart

4. 启动mysql修改root用户密钥,具体操作如下:

$ mysql
mysql> use mysql
mysql> update mysql.user set authentication_string=password('qwer1111') where user='root' and Host ='localhost';
mysql> update user set plugin="mysql_native_password"; 
mysql> flush privileges;
mysql> quit;
Bye


5.  回到/etc/mysql/mysql.conf.d/mysqld.cnf,把“skip-grant-tables”注释掉

6. 重启mysql服务sudo service mysql restart

7. 执行"mysql -u root -p",输入密码后登录成功

你可能感兴趣的:(MySQL,Linux,Server,Linux)