第一步尼酿,更新mysql源
https://dev.mysql.com/downloads/repo/yum/ 進入這個頁面選擇下面這個點擊下載,進入下載頁面得到下載網(wǎng)址。
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
下載下來,然后安裝更新源
sudo rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
安裝源默認的是mysql8.0, 所以要改一下,改成5.7匙监。
修改安裝源默認為mysql5.7
可以用這個命令看看都有哪些源
yum repolist all | grep mysql
下一步,把mysql8.0改成disabled小作, mysql5.7改成enable亭姥。
shell> sudo yum-config-manager --disable mysql80-community
shell> sudo yum-config-manager --enable mysql57-community
yum-config-manager 沒安裝的話可以下面這種方法:直接打開/etc/yum.repos.d/mysql-community.repo
修改, 只改2個地方,8.0的enabled改成0顾稀,5.7的enabled改成1达罗。
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
保存后就可以安裝了.
安裝
sudo yum install mysql-community-server
啟動Mysql
sudo systemctl start mysqld.service
sudo systemctl status mysqld.service
查看mysql安裝時的默認密碼
sudo grep 'temporary password' /var/log/mysqld.log
記下密碼,登錄mysql修改密碼
mysql -u root -p
.........
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
安裝結(jié)束础拨!加下來開啟遠程連接
1: 防火墻開3306
iptables -I INPUT -s 0/0 -p tcp --dport 3306 -j ACCEPT
- 允許root遠程連接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YourPassword' WITH GRANT OPTION;
flush privileges;