mysql -u root -p
2.更改加密方式:
mysql> ALTER USER "root"@"%" IDENTIFIED BY "password" PASSWORD EXPIRE NEVER;
3.更改密码:
mysql> ALTER USER "root"@"%" IDENTIFIED WITH mysql_native_password BY "password";
4.刷新:
mysql> FLUSH PRIVILEGES;
// 如果报错 ERROR 1396 (HY000): Operation ALTER USER failed for "root"@"%" :
则是远程访问权限不正确,先选择数据库,查看一下再更改:
mysql> use mysql;
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
rows in set (0.00 sec)
参照 原文链接: http://www.cnblogs.com/shiysin/p/shiysin.html