mysql报错:--initialize specified but the data directory has files in it. Aborting.

我的环境: redhat6.5
数据库版本: mysql5.7
问题: mysql安装好之后,初始化报错
安装方式: rpm包直接安装

问题原因:
mysql在进行初始化的时后,会检测数据目录是否存在,
如过不存在,mysql会创建它,
如果存在,而且这个目录里有数据,mysql会报错,并且终止初始化:

[root@server1 ~]# /etc/init.d/mysqld start
Initializing MySQL database:  2017-06-26T02:33:40.212541Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-26T02:33:40.215791Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-06-26T02:33:40.215877Z 0 [ERROR] Aborting

解决方法:
将这个数据目录删掉,或者重命名,如果数据比较重要,建议重命名,后期再重新导入就ok了
我用的rpm包安装,默认数据目录在
/var/lib/mysql/

我将它直接删掉

rm -fr /var/lib/mysql

完了重启,成功:

[root@server1 lib]# /etc/init.d/mysqld restart
Stopping mysqld:                                           [  OK  ]
Initializing MySQL database:                               [  OK  ]
Installing validate password plugin:                       [  OK  ]
Starting mysqld:                                           [  OK  ]

你可能感兴趣的:(学习日记)