mysql创建用户后无法访问数据库的问题

1.停止mysql服务器

sudo service mysql stop

2.启动mysql服务

sudo mysqld_safe --skip-grant-tables

3.登陆 mysql

mysql

4.重新载入权限

flush privileges;

5.进入数据库

use mysql

6.查询user用户

select user,host,password from user

7.向root用户授予权限

GRANT USAGE ON *.* TO 'root'@'localhost' IDENTIFIED BY 'Password' WITH GRANT OPTION;

8.刷新,退出

flush privileges;

exit;

此时便可以访问数据库了!!!

猜你喜欢

转载自www.cnblogs.com/ConnorShip/p/10917085.html