環境是阿裡雲的CentOS7.0,更新了yum源(更新yum源請參考https://help.aliyun.com/knowledge_detail/5974184.html)之後先是嘗試安裝了MySQL5.7,但是折騰了一下午沒有解決初始密碼的問題。項目進度很緊,索性推倒重來上MySQL5.7。今 ...
環境是阿裡雲的CentOS7.0,更新了yum源(更新yum源請參考https://help.aliyun.com/knowledge_detail/5974184.html)之後先是嘗試安裝了MySQL5.7,但是折騰了一下午沒有解決初始密碼的問題。項目進度很緊,索性推倒重來上MySQL5.7。今天總算裝好了。以下是基本步驟:(可以跳過卸載這一步)
1.卸載原mysql
1 #列出安裝的mysql 2 rpm -qa | grep mysql
1 #幹掉列出的items 2 rpm -e [item1] 3 rpm -e [item2] 4 rpm -e [item3]
由於5.7基於mariadb,所以還必須卸掉它:
1 #列出 2 rpm -qa | grep mariadb
1 #卸載 2 rpm -e mariadb-devel-5.5.44-2.el7.centos.x86_64 3 rpm -e mariadb-libs-5.5.44-2.el7.centos.x86_64
刪除相關文件夾
find / -name mysql #將列出的文件夾一一刪除。
2.下載MySQL(RPM Bundle)
地址不一定存在,所以去官網複製一下比較保險,官網找到MySQL Community Server,platform我選的是Linux-Generic.
註意要選這個RPM Bundle,其他版本是編譯安裝的,只有帶RPM Bundle的是RPM合集包。點Dowlaod去下一頁:
複製這個 No thanks 的鏈接地址就是我們需要的鏈接地址。
3.安裝MySQL5.5.48
回到linux,使用剛纔複製的地址:
mkdir /usr/local/src/mysql cd /usr/local/src/mysql wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-5.5.48-1.linux2.6.x86_64.rpm-bundle.tar
下載完畢,tar -xf MySQL-5.5.48-1.linux2.6.x86_64.rpm-bundle.tar
ls 應該能看到如下:
需要依次安裝 client devel server (community-release我也裝了)
安裝的時候有幾次報錯如下:
error: Failed dependencies: libc.so.6 is needed by MySQL-client-5.5.48-1.linux2.6.i386 libc.so.6(GLIBC_2.0) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libc.so.6(GLIBC_2.1) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libc.so.6(GLIBC_2.1.3) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libc.so.6(GLIBC_2.2) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libc.so.6(GLIBC_2.3) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libdl.so.2 is needed by MySQL-client-5.5.48-1.linux2.6.i386 libdl.so.2(GLIBC_2.0) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libdl.so.2(GLIBC_2.1) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libm.so.6 is needed by MySQL-client-5.5.48-1.linux2.6.i386 libm.so.6(GLIBC_2.0) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libncurses.so.5 is needed by MySQL-client-5.5.48-1.linux2.6.i386 libpthread.so.0 is needed by MySQL-client-5.5.48-1.linux2.6.i386 libpthread.so.0(GLIBC_2.0) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libpthread.so.0(GLIBC_2.1) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libpthread.so.0(GLIBC_2.2) is needed by MySQL-client-5.5.48-1.linux2.6.i386 libpthread.so.0(GLIBC_2.3.2) is needed by MySQL-client-5.5.48-1.linux2.6.i386 librt.so.1 is needed by MySQL-client-5.5.48-1.linux2.6.i386 librt.so.1(GLIBC_2.2) is needed by MySQL-client-5.5.48-1.linux2.6.i386
error: Failed dependencies: libaio.so.1 is needed by MySQL-server-5.5.48-1.linux2.6.i386 libaio.so.1(LIBAIO_0.1) is needed by MySQL-server-5.5.48-1.linux2.6.i386 libaio.so.1(LIBAIO_0.4) is needed by MySQL-server-5.5.48-1.linux2.6.i386
整理了一下,基本上安裝以下幾個依賴(如果yum源沒有這些包,可以嘗試更新一下https://help.aliyun.com/knowledge_detail/5974184.html)
1 yum -y install glibc.i686 2 yum -y install libncurses.so.5 3 yum -y install libaio.so.1 4 yum -y install libz.so.1
安裝完畢再次嘗試安裝MySQL5.5,這次沒問題了:
1 rpm -ivh MySQL-server-5.5.48-1.linux2.6.i386.rpm 2 rpm -ivh MySQL-devel-5.5.48-1.linux2.6.i386.rpm 3 rpm -ivh MySQL-client-5.5.48-1.linux2.6.i386.rpm 4 rpm -ivh mysql57-community-release-el7-7.noarch.rpm 5 #以下並不必須 6 rpm -ivh MySQL-embedded-5.5.48-1.linux2.6.i386.rpm 7 rpm -ivh MySQL-shared-5.5.48-1.linux2.6.i386.rpm 8 rpm -ivh MySQL-shared-compat-5.5.48-1.linux2.6.i386.rpm 9 rpm -ivh MySQL-test-5.5.48-1.linux2.6.i386.rpm
啟動:
service mysql start
這裡我遇到一個問題,似乎是還有原來的mysql進程沒有殺乾凈,我使用了ps -ef | grep mysql,然後kill -9 了列出的進程,就啟動成功了。
測試:
perfect!!
dreamingodd原創文章,如轉載請註明出處。