切换数据库,查看权限
mysql> use mysql;
Database changed
mysql> select host,user,plugin,authentication_string from user where user = 'root';
+-----------+------+-----------------------+------------------------------------------------------------------------+
| host | user | plugin | authentication_string |
+-----------+------+-----------------------+------------------------------------------------------------------------+
| % | root | caching_sha2_password | $A$005$ru3S) >y(Z3@il]wvVwxn/VoB7KXrDWmV9eQvw2NMFQrbYOKo.WGlhU1M3/ |
| localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------+-----------------------+------------------------------------------------------------------------+
2 rows in set (0.00 sec)
更改密码
方式一
登录mysql执行以下语句
mysql -u root -p
按回车确认, 如果安装正确且 MySQL 正在运行, 会得到以下响应:
Enter password:
若密码存在, 输入密码登录, 不存在则直接按回车登录。登录成功后你将会看到 Welcome to the MySQL monitor… 的提示语。
修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
出现Query OK, 0 rows affected (0.36 sec),表示修改成功。