雲伺服器Yum安裝mysql5 7並設定遠端訪問

2021-10-24 14:21:48 字數 1462 閱讀 9474

1.按順序執行以下命令即可完成mysql的安裝

wget -i -c 

yum -y install mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql-community-server

2.啟動mysql,並設定開啟自動啟動

systemctl start  mysqld.service

systemctl enable mysqld

3.檢視mysql執行狀態,active(running)則成功啟動

systemctl status mysqld.service
4.獲取mysql隨機密碼

grep "password" /var/log/mysqld.log
5.進入mysql,輸入以下命令按回車再輸入獲取到的隨機密碼

mysql -uroot -p
6.修改mysql的安全規則,此操作可省略

mysql> set global validate_password_policy=0;

mysql> set global validate_password_length=1;

7.修改mysql的預設密碼

mysql> alter user 'root'@'localhost' identified by '自定義密碼';
8.修改mysql訪問許可權

mysql> use mysql;

mysql> update user set host='%' where user='root' and host='localhost';

9.檢視許可權root的host為%即成功

mysql> select host,user from user;

+-----------+---------------+

| host | user |

+-----------+---------------+

| % | root |

| localhost | mysql.session |

| localhost | mysql.sys |

+-----------+---------------+

10.重新整理mysql使配置生效並退出

mysql>flush privileges

mysql> exit;

11.在雲伺服器的安全組規則中開放3306埠即可訪問

12.剛買的伺服器預設沒有啟動防火牆,如果啟動防火牆則需要在防火牆中開放3306埠

MySQL5伺服器快速安裝

mysqld nt.exe install net start mysql 1detailed configuration 2server machine 伺服器型別,mysql占用較多資源 2transactional database only 伺服器型別,專注於事務處理,一般 next 3ma...

MySQL5伺服器快速安裝

mysqld nt.exe install net start mysql 1detailed configuration 2server machine 伺服器型別,mysql占用較多資源 2transactional database only 伺服器型別,專注於事務處理,一般 next 3ma...

使用MySQL的yum源安裝MySQL5 7

一 安裝配置mysql的yum源1 安裝yum config manager yuminstallyum utils y 禁用mysql5.6的源 yum config manager disable mysql56 community 啟用mysql5.7的源 yum config manager...