1、安装
sudo apt-get install mysql-server
2、验证
systemctl status mysql
3、配置
sudo mysql_secure_installation
4、登陆MySQL
sudo mysql -u root -p
5、远程连接配置
1、打开文件注释掉bind-address=127.0.0.1
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
2、重启MySQL服务
sudo /etc/init.d/mysql restart
3、连接MySQL
$ sudo mysql -u root -p
4、创建远程连接账户并授权
mysql> use mysql;
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
mysql> grant all privileges on *.* to 'root'@'%';
密码简单了,请设置成复杂密码
5、远程连接时报错plugin caching_sha2_password could not be loaded 执行
set global validate_password.policy=LOW;
set global validate_password.length=6;
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
6、刷新权限
mysql> FLUSH PRIVILEGES;
7、查看用户
mysql> select host, user, authentication_string, plugin from user;