Mysql rpm安裝(version:mysql-community-5.7.19-1.el7)

  • 進(jìn)入官網(wǎng)下載頁面
  • 點(diǎn)擊Community (GPL) Downloads ?
  • 選擇操作系統(tǒng)Select Operating System:(此處選的是Red Hat Enterprise Linux)
  • 選擇操作系統(tǒng)版本Select OS Version:(此處選的是Red Hat Enterprise Linux 7(x86,64-bit))
  • 查看下載列表,點(diǎn)擊下載(此處選mysql-version.x86_64.rpm-bundle.tar)
  • 上傳到linux服務(wù)器
  • 解壓
# tar 的-C選項(xiàng)可指定解壓路徑
#tar -C ./mysql_installer -xvf mysql-version.x86_64.rpm-bundle.tar
 tar -xvf mysql-version.x86_64.rpm-bundle.tar
  • 安裝前準(zhǔn)備
# Centos6,Red hat6
# 查詢已安裝的mysql相關(guān)軟件包
rpm -qa | grep -i mysql  
# 用rpm -e --nodeps 軟件包名卸載上面列出的軟件包
rpm -e --nodeps mysql-libs-version.x86_64 
# Red hat 7,Centos7
# 查詢已安裝的mariadb相關(guān)軟件包
rpm -qa | grep -i mariadb  
# 用rpm -e --nodeps 軟件包名卸載上面列出的軟件包
rpm -e --nodeps mariadb-libs-version.x86_64 
  • 文件安裝順序(不能亂,有依賴關(guān)系)
rpm -ivh mysql-community-common-version.x86_64.rpm  
rpm -ivh mysql-community-libs-version.x86_64.rpm  
rpm -ivh mysql-community-client-version.x86_64.rpm  
# 這一步可能會(huì)報(bào)error: Failed dependencies:
#  libaio.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
# libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
#  libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
# net-tools is needed by mysql-community-server-5.7.16-1.el7.x86_64
# 可以去http://mirror.centos.org/centos/7/os/x86_64/Packages/下載libaio和net-tools安裝
# 之后再進(jìn)行mysql-server
rpm -ivh mysql-community-server-version.x86_64.rpm  
  • vim /etc/my.cnf 添加字符集支持中文
# 按i鍵使vim進(jìn)入insert模式
[client]
default-character-set=utf8mb4

[mysqld]
character_set_server=utf8mb4
# 按esc使vim退出insert模式直接輸入:wq保存并退出
  • 啟動(dòng)mysql
service mysqld start 
或
systemctl start mysqld
  • 獲取初始密碼
grep 'temporary password' /var/log/mysqld.log
  • 修改初始密碼
mysql -uroot -p'初始密碼'  
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密碼'; 
# 這里你可能遇到ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
# 你需要:
set global validate_password_policy=0;
set global validate_password_length=4;
set PASSWORD = PASSWORD('123456');
  • 放開防火墻、設(shè)定自啟動(dòng)、增強(qiáng)MySQL安全設(shè)置等
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT  
/etc/init.d/iptables save  
chkconfig mysqld on  
mysql_secure_installation 
  • 更新到mysql-community-8.0.11-1.el7.x86_64產(chǎn)生的問題,mysql 5.7版本和8.0版本是不兼容的,你使用rpm安裝的5.7,使用rpm -e卸載之后數(shù)據(jù)文件還是存在的,mysql 8.0是啟動(dòng)不起來的,啟動(dòng)mysqld服務(wù)的時(shí)候,另開一個(gè)窗口,tail -f /var/log/mysqld.log打印日志,你就會(huì)發(fā)現(xiàn)Cannot upgrade server earlier than 5.7 to 8.0這句話,你要做的是把之前遺留的數(shù)據(jù)庫文件也刪掉或者移動(dòng)到其他地方,即rm -rf /var/lib/mysql/*,日志文件的路徑及數(shù)據(jù)庫文件路徑來源https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html,其實(shí)只要把版本號(hào)換一下就是各個(gè)版本的rpm安裝教程
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容