MySQL 8.0.x 安装后配置远程链接和修改root密码
1.安装MySQL
1
| sudo apt install mysql-server
|
2.登录MySQL,修改root密码
1 2 3 4 5 6 7 8 9
| sudo mysql
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '410000'; FLUSH PRIVILEGES;
|
3.配置远程连接用户
1 2 3
| CREATE USER 'root'@'%' IDENTIFIED BY '410000'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;
|
修改配置文件中MySQL的监听ip和端口
1
| sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
|
找到 bind-address = 127.0.0.1
并将其更改为 #bind-address = 127.0.0.1
4.重启MySQL
1
| sudo systemctl restart mysql
|