1.清理环境
由于centos默认安装有mariadb,所以需要查询你的系统是否存在,存在则删除
rpm -qa | grep mari*
建议使用yum删除
2.缺少依赖的情况
如果安装失败,提示缺少依赖,基本上是这个错误
[root@lnmp ~]# rpm -ivh MySQL-server-5.6.20-1.el7.x86_64.rpm
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.6.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.20-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.20-1.el7.x86_64
解决方法:
[root@lnmp ~]# yum install libaio
3.兼容性问题
[root@lnmp ~]# rpm -ivh MySQL-server-5.6.20-1.el7.x86_64.rpm
Preparing... ################################# [100%]
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
出现这种情况是因为后面的那个软件不兼容,建议yum卸载
yum remove mariadb-libs-1:5.5.60-1.el7_5.x86_64
4.缺少依赖包
当安装时候出现这个提示是因为缺少autoconf这个依赖包
[root@lnmp ~]# rpm -ivh MySQL-server-5.6.20-1.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:MySQL-server-5.6.20-1.el7 ################################# [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper
还是建议yum安装
yum -y install autoconf
5.问题解决完,重新运行安装命令
[root@lnmp ~]# rpm -ivh MySQL-server-5.6.20-1.el7.x86_64.rpm
Preparing... ################################# [100%]
package MySQL-server-5.6.20-1.el7.x86_64 is already installed
[root@lnmp ~]# /usr/bin/mysql_install_db
Installing MySQL system tables...2020-08-17 10:43:51 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
如果是像我一样一步一步做的,出现各种问题之后再解决,最后安装的时候需要/usr/bin/mysql_install_db
6.安装完成注意提示修改密码
如果你只是安装了sever服务器端,需要再安装一个clint工具包,才能执行mysql的管理命令。