在CentOS 7.0 上安裝 MySQL 5.5 步驟如下:
1. 官網下載MySQL 5.5的rpm包,本文以5.5.52為例:
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-5.5.52-1.el7.x86_64.rpm-bundle.tar
2. 解壓并安裝rpm包:
tar xf MySQL-5.5.52-1.el7.x86_64.rpm-bundle.tar yum install MySQL-server-5.5.52-1.el7.x86_64.rpm MySQL-client-5.5.52-1.el7.x86_64.rpm MySQL-devel-5.5.52-1.el7.x86_64.rpm -y
3. 啟動mysql服務:
systemctl start mysqld.service
4. 初次啟動mysql服務,獲取初始隨機密碼:
grep "temporary password" /var/log/mysqld.log
5. 登錄mysql:
mysql -u root -p
6. 輸入上一步獲取的臨時密碼,進入mysql命令行,修改密碼:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your-new-password');
7. 測試連接:
mysql -u root -p
至此,MySQL 5.5已安裝成功。