1. 程式人生 > 其它 >ubuntu20.04 配置mysql8.0

ubuntu20.04 配置mysql8.0

安裝過程詢問一般 y 就可以了

1 安裝

1.1 下載

wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb

1.2 安裝

dpkg -i mysql-apt-config_0.8.22-1_all.deb

安裝過程中出現選擇項,通過上下鍵選擇OK繼續安裝即可

1.4 安裝MySQL Server

更新apt軟體源

apt-get update

安裝MySQL Server

apt-get install mysql-server

1.5常用命令

# 檢視服務狀態
service mysql status

# 停止服務
service mysql stop

# 啟動服務
service mysql start

# 重啟服務
service mysql restart

#埠檢視
netstat -anp | grep mysql

2 配置外網訪問

2.1 檢視埠

naestat -an|grep 3306

2.1修改配置檔案

cd etc/mysql/mysql.conf.d

#開啟配置檔案
sudo vim mysqld.cnf

刪除 port = 3306的註釋

註釋 bind-address = 127.0.0.1

2.4 修改root密碼

# 根據提示進行輸入,問Y/N時不會就y吧
mysql_secure_installation

2.3修改使用者

# 進入mysql服務檯
mysql -h 127.0.0.1 -u root -p

#選擇mysql資料表
use mysql;

# 更改root使用者的訪問許可權
update user set host='%' where user='root';

#開放root使用者所有許可權
grant all privileges on *.* to 'root'@'%' identified by '你的root賬戶密碼';

#展示user表的兩個欄位
select host,user from user;

Ps:不要忘記放開雲主機的防火牆

Ps:不要忘記放開雲主機的防火牆

Ps:不要忘記放開雲主機的防火牆