centos6.5中rpm包安装mysql5.7(初始化出错如何解决)

下载rpm包见:http://www.cnblogs.com/grey-wolf/p/7472680.html

1、rz上传到服务器,解压缩

rz
[root@mini2 upload]# tar -xvf mysql-5.7.-.el6.i686.rpm-bundle.tar      

centos6.5中rpm包安装mysql5.7(初始化出错如何解决)

2、安装rpm包

rpm -ivh mysql-community-common-5.7.-.el6.i686.rpm
rpm -ivh mysql-community-libs-5.7.-.el6.i686.rpm
rpm -ivh mysql-community-libs-compat-5.7.-.el6.i686.rpm
rpm -ivh mysql-community-client-5.7.-.el6.i686.rpm
rpm -ivh mysql-community-server-5.7.-.el6.i686.rpm

注意:如果不是全新安装,而是之前用rpm装过,没装好,又卸载的情况下安装,可能会出现如下情况:

在执行rpm -ivh mysql-community-server-5.7.19-1.el6.i686.rpm时,如果出现如下输出:

centos6.5中rpm包安装mysql5.7(初始化出错如何解决)

centos6.5中rpm包安装mysql5.7(初始化出错如何解决)

有比较大的可能是因为数据目录没有清空,我们再往下手动初始化看看,执行以下命令:

[root@mini2 upload]# mysqld --initialize --user=mysql
--29T05::.750237Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
--29T05::.754943Z [ERROR] --initialize specified but the data directory has files in it. Aborting.
--29T05::.755064Z [ERROR] Aborting

发现报错了,拿错误信息在百度上找了瞎,发现需要清空数据目录:

从官方的文档看到,数据目录位置:

centos6.5中rpm包安装mysql5.7(初始化出错如何解决)

那就清空了再试试吧。

[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
--29T05::.613275Z [Note] A temporary password is generated for root@localhost: tzqjMvkHH3+C
--29T05::.340338Z [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 '';
grant all privileges on *.* to 'root'@'%' identified by '' with grant option 
参考了:(可以看到,里面的红色字体,也是提示一定要删除那个数据目录)
http://blog.csdn.net/testcs_dn/article/details/39502475
上一篇:Berkeley DB的常见API简单分析


下一篇:开发宏功能:excel中从sheet批量插入