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