之前安裝的目錄爲/usr/local/develope/mysql
後來改了下目錄 同時也改了MySQL文件夾名
現在爲/usr/local/develope/develop/mysql5.6 同時data目錄還是在的
配置文件已經修改
MySQL在安裝或者啓動的時候沒有指定配置文件時候 默認找的配置文件/etc/my.cnf
將basedir目錄和data目錄修改爲新的目錄(注意一定要修改對 )
basedir=/usr/local/develop/mysql5.6
datadir=/usr/local/develop/mysql5.6/data
誤區 修改了目錄後不需要重新初始化 因爲data目錄是不爲空的 除非刪除掉data目錄 重新安裝
錯誤1:無法解析的域名
root@xxx-Pro mysql5.6 # ./scripts/mysql_install_db --user=mysql
FATAL ERROR: Neither host 'xxx.Pro.local' nor 'localhost' could be looked up with
/usr/local/develope/mysql5.6/bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
解決方法 編輯 /etc/hosts文件
127.0.0.1 localhost xxx.Pro.local
保存退出 即可
同時在mysql5.6 該目錄下 運行 ./bin/resolveip localhost
IP address of localhost is 127.0.0.1
出來如下內容即爲配置成功
同樣還是誤區 不需要重新安裝 或者考慮刪除 data目錄 重新安裝
root@xxx-Pro scripts # ./mysql_install_db --user=mysql
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
解決 在scripts 目錄下 ./bin/my_print_defaults 這個文件是沒有的
需要在mysql5.6 安裝根路徑下 進行執行
錯誤原因 服務器在沒有更新PID文件的情況下退出
root@xxx-Pro mysql5.6 # ./support-files/mysql.server start
Starting MySQL
.Warning: World-writable config file '/usr/local/develop/mysql5.6/my.cnf' is ignored
Warning: World-writable config file '/usr/local/develop/mysql5.6/my.cnf' is ignored
Logging to '/usr/local/develop/mysql5.6/data/liangzhuangdeMacBook-Pro.local.err'.
.. ERROR! The server quit without updating PID file (/usr/local/develop/mysql5.6/data/liangzhuangdeMacBook-Pro.local.pid).
解決辦法
1.檢查/etc/my.cnf MySQL配置文件的 basedir配置和datadir配置是否修改正確
basedir=/usr/local/develop/mysql5.6
datadir=/usr/local/develop/mysql5.6/data
2.如果basedir配置和datadir配置修改的正確 嘗試刪除 /etc/my.cnf 文件 (注意備份)然後重新啓動MySQL