1、root登录mysql之后,查看端口,确认是3306
show variables like ‘port‘;
2、添加root@%用户并设置密码为123456
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
如果出现这样的错误:
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决方法:flush privileges;
3、查看用户列表
use mysql;
select host,user,password from user;
Done!