环境是阿里云的CentOS7.0,更新了yum源(更新yum源请参考https://help.aliyun.com/knowledge_detail/5974184.html)之后先是尝试安装了MySQL5.7,但是折腾了一下午没有解决初始密码的问题。项目进度很紧,索性推倒重来上MySQL5.5。今天总算装好了。以下是基本步骤:(可以跳过卸载这一步)
1.卸载原mysql
#列出安装的mysql
rpm -qa | grep mysql
#干掉列出的items
rpm -e [item1]
rpm -e [item2]
rpm -e [item3]
由于5.7基于mariadb,所以还必须卸掉它:
#列出
rpm -qa | grep mariadb
#卸载
rpm -e mariadb-devel-5.5.-.el7.centos.x86_64
rpm -e mariadb-libs-5.5.-.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. is needed by MySQL-client-5.5.-.linux2..i386
libc.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libc.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libc.so.(GLIBC_2.1.3) is needed by MySQL-client-5.5.-.linux2..i386
libc.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libc.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libdl.so. is needed by MySQL-client-5.5.-.linux2..i386
libdl.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libdl.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libm.so. is needed by MySQL-client-5.5.-.linux2..i386
libm.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libncurses.so. is needed by MySQL-client-5.5.-.linux2..i386
libpthread.so. is needed by MySQL-client-5.5.-.linux2..i386
libpthread.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libpthread.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libpthread.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
libpthread.so.(GLIBC_2.3.2) is needed by MySQL-client-5.5.-.linux2..i386
librt.so. is needed by MySQL-client-5.5.-.linux2..i386
librt.so.(GLIBC_2.) is needed by MySQL-client-5.5.-.linux2..i386
error: Failed dependencies:
libaio.so. is needed by MySQL-server-5.5.-.linux2..i386
libaio.so.(LIBAIO_0.) is needed by MySQL-server-5.5.-.linux2..i386
libaio.so.(LIBAIO_0.) is needed by MySQL-server-5.5.-.linux2..i386
整理了一下,基本上安装以下几个依赖(如果yum源没有这些包,可以尝试更新一下https://help.aliyun.com/knowledge_detail/5974184.html)
yum -y install glibc.i686
yum -y install libncurses.so.
yum -y install libaio.so.
yum -y install libz.so.
安装完毕再次尝试安装MySQL5.5,这次没问题了:
rpm -ivh MySQL-server-5.5.-.linux2..i386.rpm
rpm -ivh MySQL-devel-5.5.-.linux2..i386.rpm
rpm -ivh MySQL-client-5.5.-.linux2..i386.rpm
rpm -ivh mysql57-community-release-el7-.noarch.rpm
#以下并不必须
rpm -ivh MySQL-embedded-5.5.-.linux2..i386.rpm
rpm -ivh MySQL-shared-5.5.-.linux2..i386.rpm
rpm -ivh MySQL-shared-compat-5.5.-.linux2..i386.rpm
rpm -ivh MySQL-test-5.5.-.linux2..i386.rpm
启动:
service mysql start
这里我遇到一个问题,似乎是还有原来的mysql进程没有杀干净,我使用了ps -ef | grep mysql,然后kill -9 了列出的进程,就启动成功了。
测试:
perfect!!
dreamingodd原创文章,如转载请注明出处。