MySQL8(密码以及远程连接的问题)
MySQL8忘记密码怎么办?
-
sudo vim /etc/mysql/my.cnf
增加如下内容,跳过密码检查。
[mysqld] #(可选) #skip-name-resolve skip-grant-tables
-
service mysql restart
-
进mysql(无需密码)
-
flush privileges;
-
update user set authentication_string=’’ where user='root’;
-
alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘newPassword’;(with mysql_native_password 可选)
注意密码的复杂性。若想设置简单密码,修改下列属性
- SHOW VARIABLES LIKE ‘validate_password%';
- set global validate_password.policy=LOW;
- set global validate_password.length=6;
另外,注意查看host是‘localhost’还是‘%’
- use mysql;
- select user,host from user;
-
sudo vim /etc/mysql/my.cnf
复原my.cnf
-
service mysql restart
-
mysql -u root -p(验证)
MySQL8配置远程连接
-
进mysql(root localhost)
-
use mysql;
-
select host, user, authentication_string, plugin from user;
-
create user ‘root’@'%’ identified by ‘你自己的mysql密码’;
-
grant all privileges on . to ‘root’@'%';
-
flush privileges;
-
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉:ind-address = 127.0.0.1
-
service mysql restart
https://blog.csdn.net/winterking3/article/details/86080434
https://blog.csdn.net/hello_world_qwp/article/details/79551789
MySQL的安装可以看这篇