前言:楼主以前一直用的CentOs6.6,准备在这个环境上安装一个最新版本的mysql-5.7.18.
于是就开始下载mysql-5.7.18的rpm安装包,然后开始安装,最重要的不能解决的问题就是GLIBC的依赖没法解决掉,因为CentOS6.6版本的GLIBC版本是2.12
安装过程出现如下错误
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libc.so.6(GLIBC_2.14)(64bit) is needed by mysql-community-libs-5.7.18-1.el7.x86_64
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.18-1.el7.x86_64
报错信息为缺少依赖的 libc.so.6(GLIBC_2.14)(64bit) ,
但是安装mysql-5.7.18需要的版本为最低2.14.网上找了很多资料,手工安装了GLIBC2.14
安装完成后, 建立软链指向glibc-2.14, 执行如下命令:
$ rm -rf /lib64/libc.so.6 // 先删除先前的libc.so.6软链
$ ln -s /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
注意
删除libc.so.6之后可能导致系统命令不可用的情况, 可使用如下方法解决:
$ LD_PRELOAD=/opt/glibc-2.14/lib/libc-2.14.so ln -s /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
另外, 执行$ ll /lib64/libc**
可以看到此时的libc.so.6是libc-2.14.so的别名, 如下图所示:
[root@localhost lib]# ll /lib64/libc**
-rwxr-xr-x. 1 root root 1930416 Apr 11 15:49 /lib64/libc-2.12.so
lrwxrwxrwx. 1 root root 32 Jun 24 09:23 /lib64/libc.so.6 -> /opt/glibc-2.14/lib/libc-2.14.so
查看系统glibc库版本可使用如下命令:
[root@localhost mysql]# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
如上所示已经有glibc2.14了。
但是最后没有成功。安装mysql依然报错
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libc.so.6(GLIBC_2.14)(64bit) is needed by mysql-community-libs-5.7.18-1.el7.x86_64
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.18-1.el7.x86_64
最后没办法转战CentOS7系统了,因为CentOS7默认Glibc版本为2.17是可以满足安装mysql-5.7.18版本的依赖的。
所以写在前面,让还在使用CentOS6的小伙伴们,如果想要安装高版本的mysql,请放弃6,使用7吧。
记得一定要先卸载,不然会出现包冲突的问题。
由于是.tar包,所以解压的时候要用-xvf,而不要使用-zxvf是解压.tar.gz的。
解压:[root@localhost mysql]#tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
mysql-community-server-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-client-5.7.18-1.el7.x86_64.rpm
mysql-community-common-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
mysql-community-test-5.7.18-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.18-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.18-1.el7################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.18-1.e################################# [100%]
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.18-1.e################################# [100%]
[root@localhost mysql]#
这里演示使用的 --initialize 初始化的,会生成一个 root 账户密码,密码在log文件里,红色的就是自动生成的密码
[root@localhost mysql]# cat /var/log/mysqld.log
2017-06-24T16:47:12.709474Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-24T16:47:12.590590Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-06-24T16:47:12.000269Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-06-24T16:47:12.109868Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 960c533e-49fb-11e7-91f2-00163e089fd2.
2017-06-24T16:47:12.116186Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-06-24T16:47:12.116777Z 1 [Note] A temporary password is generated for root@localhost: :qqeftsut3wj
使用 service 启动:service mysqld start
使用 service 启动:service mysqld stop
修改密码:set password = password('你的密码');
创建对象并赋予权限
grant all privileges on *.* to 'dev' @'%' identified by '123456';
flush privileges;
vi /etc/my.cnf
如果文件中有bind-address = 127.0.0.1而且前面没有#注释进行下面的步骤
注释掉#bind-address = 127.0.0.1,如果没有就不用修改。
然后重启mysql
使用 service 启动:service mysqld restart
加入到系统服务:
chkconfig --add mysqld
自动启动:
chkconfig mysqld on
然后执行reboot now,重启系统
然后执行ps -ef | grep mysql
[root@localhost etc]# ps -ef |grep mysql
root 1941 1 0 Jun23 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 2040 1941 0 Jun23 ? 00:00:23 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 11372 11055 0 10:03 pts/0 00:00:00 grep mysql
Centos7中防火墙变为了firewall,所以千万不要在使用iptable去关闭了。
1 查看防火墙状态
[root@localhost mysql]# firewall-cmd --state
running
2 果然是运行的,于是就想disabled防火墙服务
[root@localhost mysql]# systemctl mask firewalld
ln -s '/dev/null' '/etc/systemd/system/firewalld.service'
3 然后关闭防火墙
[root@localhost mysql]# systemctl stop firewalld
4 最后检查防火墙服务,发现已经关闭了
[root@localhost mysql]# firewall-cmd --state
not running
可以看见已经启动起来了。到此为止,mysql安装完毕。