ubuntu安装mysql设置远程连接.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#设置yum源,修改为阿里云源

vim /etc/apt/source.list
#查找替换
:1,$s/cn.archive.ubuntu.com/mirrors.aliyun.com/g

#更新yum源

apt-get update

#下载mysql-server
apt install mysql-server -y
systemctl status mysql
systemctl enable mysql

#进入mysql
mysql -u root -p
#输入任意密码即可

#修改数据库密码
alter user 'root'@'localhost' identified by "root";
flush privileges;
#授权远程登录
update user set host='%' where user='root' and host='localhost';
alter user 'root'@'%' identified with mysql_native_password by 'abc123'
flush privileges

vim /etc/mysql/mysql.conf.d/mysqld.cnf
#注释掉 bind-address = 127.0.0.1

#注释mysqlx-bind-address  = 127.0.0.1

#重启mysql
systemctl restart mysql

#远程连接测试成功