您的位置:首页 > 数据库 > MySQL

第一次打开mysqlshi报错“Accerss denied for user 'root'@local

2016-04-03 17:39 501 查看
可以依次执行下面几步:

1.Start the MySQL server instance or daemon with the –skip-grant-tables option (security setting).

$ mysqld --skip-grant-tables


2.Execute these statements.

$ mysql -u root mysql


$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';


$mysql> FLUSH PRIVILEGES;


3.Finally, restart the instance/daemon without the –skip-grant-tables option.

$ /etc/init.d/mysql restart


然后就可以了 stackoverflow的链接:http://superuser.com/questions/603026/mysql-how-to-fix-access-denied-for-user-rootlocalhost

如果上面还不行可能是没关闭mysql服务:

1. mysqld –skip-grant-tables

2. mysql -u root

3. use mysql;

4. update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;

5. flush privileges;

6. quit

然后,关闭mysql 服务

5.7 mysql的密码字段改名了
“password” => "authentication_string"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: