【实施工程师之家】linux安装mysql(yum安装mysql)
生活随笔
收集整理的這篇文章主要介紹了
【实施工程师之家】linux安装mysql(yum安装mysql)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
目錄
查看環(huán)境
修改下載位置
安裝 repo 包
安裝 MySQL
啟動(dòng)MySQL
設(shè)置開機(jī)自啟
登錄MySQL
修改密碼
外網(wǎng)訪問
?
防火墻設(shè)置,開放3306端口
查看環(huán)境
rpm -qa | grep mysql說明沒有安裝mysql
如果有:
rpm -e --nodeps mysql強(qiáng)力刪除模式,如果使用上面命令刪除時(shí),提示有依賴的其它文件,則用該命令可以對(duì)其進(jìn)行強(qiáng)力刪除,在刪除完以后我們可以通過 rpm -qa | grep mysql 命令來查看mysql是否已經(jīng)卸載成功!!
修改下載位置
cd /usr/local/src wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm安裝 repo 包
rpm -ivh mysql-community-release-el7-5.noarch.rpm yum repolist all安裝 MySQL
yum install -y mysql-server啟動(dòng)MySQL
systemctl start mysql設(shè)置開機(jī)自啟
systemctl enable mysqld登錄MySQL
mysql_secure_installation In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.以登錄到MySQL的安全,我們需要的電流根用戶密碼。如果你剛剛安裝MySQL,你還沒有設(shè)置root密碼,密碼將是空白的,所以你應(yīng)該在這里按回車。
登錄成功。
修改密碼
選中【MySQL】數(shù)據(jù)庫
use mysql;輸入修改密碼語句??
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';改完密碼刷新一下權(quán)限
FLUSH PRIVILEGES;外網(wǎng)訪問
update user set host='%' where user='root' and host='localhost';如果是在線的,例如是阿里的【ECS】服務(wù)器添加對(duì)應(yīng)【安全組】即可
不是的話得自己設(shè)置開放3306端口,如下:
防火墻設(shè)置,開放3306端口
# 安裝 iptables yum install iptables iptables-services iptables-utils systemctl start iptables systemctl status iptables# 設(shè)置iptables iptables -I INPUT -p tcp --dport 3306 -j ACCEPT iptables -I INPUT -p udp --dport 3306 -j ACCEPT iptables -nL# 設(shè)置firewalld firewall-cmd --state firewall-cmd --permanent --zone=public --add-port=3306/tcp firewall-cmd --permanent --zone=public --add-port=3306/udp# 重啟 systemctl restart firewalld.service # 或者 firewall-cmd --reload希望能給大家?guī)硪欢ǖ膸椭?#xff0c;歡迎一鍵三連。?
總結(jié)
以上是生活随笔為你收集整理的【实施工程师之家】linux安装mysql(yum安装mysql)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP字符串增强加密
- 下一篇: mysql全文索引FULLTEXT的哈希