1、rz上传到服务器,解压缩
rz [root@mini2 upload]# tar -xvf mysql-5.7.19-1.el6.i686.rpm-bundle.tar
2、安装rpm包
rpm -ivh mysql-community-common-5.7.19-1.el6.i686.rpm rpm -ivh mysql-community-libs-5.7.19-1.el6.i686.rpm rpm -ivh mysql-community-libs-compat-5.7.19-1.el6.i686.rpm rpm -ivh mysql-community-client-5.7.19-1.el6.i686.rpm rpm -ivh mysql-community-server-5.7.19-1.el6.i686.rpm
注意:如果不是全新安装,而是之前用rpm装过,没装好,又卸载的情况下安装,可能会出现如下情况:
在执行rpm -ivh mysql-community-server-5.7.19-1.el6.i686.rpm时,如果出现如下输出:
有比较大的可能是因为数据目录没有清空,我们再往下手动初始化看看,执行以下命令:
[root@mini2 upload]# mysqld --initialize --user=mysql 2017-08-29T05:22:18.750237Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-29T05:22:18.754943Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2017-08-29T05:22:18.755064Z 0 [ERROR] Aborting
发现报错了,拿错误信息在百度上找了瞎,发现需要清空数据目录:
从官方的文档看到,数据目录位置:
那就清空了再试试吧。
[root@mini2 upload]# rm -rf /var/lib/mysql/*
接下来初始化:
mysqld --initialize --user=mysql
接下来启动mysql:
[root@mini2 upload]# service mysqld start
正在启动 mysqld: [确定]
3、查找初始密码(我这边之所以有两个密码,应该就是之前没卸载干净,直觉应该用后边的新密码登录)
[root@mini2 upload]# grep 'temporary password' /var/log/mysqld.log 2017-08-29T05:00:02.613275Z 1 [Note] A temporary password is generated for root@localhost: tzqjMvkHH3+C 2017-08-29T05:31:51.340338Z 1 [Note] A temporary password is generated for root@localhost: Adgwggdr%1e2
4、登录
[root@mini2 upload]# mysql -uroot -p
我这边登录是ok了,密码用的Adgwggdr%1e2
5、修改密码并允许其他机器上客户端登录
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option
总结
以上所述是小编给大家介绍的centos6.5中rpm包安装mysql5.7初始化出错的解决方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!