1、执行安装指令
sql
sudo apt-get update
sudo apt-get install mysql-server
2、安装成功后,设置密码
sql
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'ysw1234';
flush privileges;
3、设置允许远程连接并生效
sql
use mysql;
update user set host = '%' where user = 'root';
flush privileges;
编辑配置文件
bash
vim /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]下添加
sql
[mysqld]
...
bind-address = 0.0.0.0
4、重启mysql
bash
systemctl restart mysql