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文件夾來備份原來的數據嗎?要知道哪個新人上來不會反覆折騰幾次的,這種問題很容易勸退新人。當然你是工作需要的話,硬着頭皮也要上,畢竟有些問題,你現在不解決,以後還會遇上。

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