进入MySQL:mysql -uroot -p
进入mysql数据库:use mysql;
查询用户和密码:select host,user,authentication_string from user;
修改root数据库密码:alter user root@"%" identified by "123456";
注意root和%:%代表任何客户机都可以连接;localhost代表只可以本机连接。
你的身份基于2个信息:主机连接,用户名。身份检查使用user表(Host, User和Password)范围列执行。
----------
设置免密:vim /etc/my.cnf,添加skip-grant-tables,保存退出,重启mysql即可免密登录mysql