mysql 8.0使用了新的密码加密方式,不再使用
mysql_native_password。
输入 sudo cat /etc/mysql/debian.cnf
显示
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = ndUmfWzlZffKdS5sqd
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = ndUmfWzlZKdS5sqd
socket = /var/run/mysqld/mysqld.sock
使用mysql -u debian-sys-maint -p登录
SELECT User,Host,plugin FROM mysql.user WHERE user='root';
+------+-----------+-------------+
| User | Host | plugin |
+------+-----------+-------------+
| root | localhost | auth_socket |
+------+-----------+-------------+
使用auth_socket认证
修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '123456';
flush privileges;
刷新权限
exit
如果使用远程登陆
运行
UPDATE mysql.user SET Host='%' WHERE User='root' AND Host='localhost';
运行
flush privileges;
% 就是不限制登录地址,同时主要修改配置文件中bind-address
然后设置
ALTER USER root IDENTIFIED WITH caching_sha2_password BY '123456';
{BANNED}最佳后运行
flush privileges;
因为很多工具远程连接mysql有问题
建议使用
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
如果提示
[ERROR] unknown variable 'default_authentication_plugin=mysql_native_password'
修改/etc/mysql/mysql.conf.d目录下mysqld.cnf文件后重启MySQL:
[mysqld]
default_authentication_plugin=mysql_native_password
阅读(2110) | 评论(0) | 转发(0) |