mysqld启动报错: [ERROR] --initialize specified but the data directory has files in it. Aborting

参照百度翻译(英语水平好的同学不用翻译工具,仔细看就行):

大意是数据目录有文件所以终止初始化。

原因:我在之前有安装其他版本的mysql,在卸载的时候数据文件目录没有清理干净,所以造成这个问题。

解决:清理掉这个目录就好了,那这个目录在哪里呢? 查看配置文件cat /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

datadir=....这个就是对应的数据目录了。进入这个目录rm -rf *就行了

吐槽:mysql的这个功能大概是怕把服务器上原来的数据文件直接覆盖掉造成已有数据丢失才会这样的吧,但是你不能像windows升级一样搞个windows.old文件夹来备份原来的数据吗?要知道哪个新人上来不会反复折腾几次的,这种问题很容易劝退新人。当然你是工作需要的话,硬着头皮也要上,毕竟有些问题,你现在不解决,以后还会遇上。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章