MySQL報錯:Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
1. 要對MySQL數(shù)據(jù)庫清除原來已有的數(shù)據(jù),重新初始化數(shù)據(jù)庫。
Linux系統(tǒng):CentOS7.6,數(shù)據(jù)庫:MySQL5.6.40。先將mysql進程強行停止掉。
pkill mysqld
2. 對數(shù)據(jù)庫進行清理:
[root@mv172 ~]# rm -rf /application/mysql/data/* [root@mv172 ~]# \rm -rf /data/mysql/*
3. 配置文件安裝在/application/mysql-5.6.40/my.cnf
[mysqld] basedir=/application/mysql datadir=/application/mysql/data socket=/tmp/mysql.sock log_error=/var/log/mysql.log log_bin=/data/mysql/mysql-bin binlog_format=row skip-name-resolve server_id=172 gtid-mode=on enforce-gtid-consistency=true log-slave-updates=1 [client] socket=/tmp/mysql.sock
4. 執(zhí)行數(shù)據(jù)庫初始化命令: 這次初始化沒有把配置文件添加進去,導(dǎo)致問題的開始。
[root@mv172 ~]# /application/mysql/scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/
......出現(xiàn)一堆的執(zhí)行代碼,此處就省略:
5. 將mysql啟動復(fù)制到系統(tǒng)為默認啟動路徑
[root@mv172 ~]# \cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
6. # 啟動mysql,這時候有報錯:
[root@mv172 ~]# /etc/init.d/mysqld start /etc/init.d/mysqld: line 244: my_print_defaults: command not found /etc/init.d/mysqld: line 264: cd: /usr/local/mysql: No such file or directory Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
7. 經(jīng)過不斷嘗試,終于找到問題根源。 因為起初 初始化時,沒有將mysql路徑和數(shù)據(jù)庫保存路徑綁定好,而導(dǎo)致一連串問題。
查配置文件,沒有配置的保存mysql-bin二進制保存路徑。
[root@mv172 /]# mkdir -p /data/mysql [root@mv172 /]# chown -R mysql.mysql /data/*
8. 重新初始化數(shù)據(jù),自此增加“--defaults-file=/application/mysql/my.cnf”
[root@mv172 data]# /application/mysql/scripts/mysql_install_db --defaults-file=/application/mysql/my.cnf --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
9 . # 于是查看mysqld文件
發(fā)現(xiàn)
“basedir=
datadir=”
這兩個路徑,突然想到mysql啟動順手時以這個mysqld優(yōu)先,于是將配置文件這兩個路徑添加到這里來,
# [mysqld] # basedir=<path-to-mysql-installation-directory> # - Add the above to any other configuration file (for example ~/.my.ini) # and copy my_print_defaults to /usr/bin # - Add the path to the mysql-installation-directory to the basedir variable # below. # # If you want to affect other MySQL variables, you should make your changes # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. # If you change base dir, you must also change datadir. These may get # overwritten by settings in the MySQL configuration files. basedir= datadir= ......
10 . 重新再執(zhí)行初始化數(shù)據(jù)庫,執(zhí)行
啟動數(shù)據(jù)庫命令
[root@mv172 data]# /etc/init.d/mysqld start Starting MySQL.. SUCCESS!
到此這篇關(guān)于MySQL報錯:Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)的文章就介紹到這了,更多相關(guān)Starting MySQL ERROR!內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 解決springboot項目啟動報錯Error creating bean with name dataSourceScriptDatabaseInitializer問題
- SpringBoot啟動報錯Whitelabel Error Page: This application has no explicit mapping for的解決方法
- 解決修復(fù)報錯Error in render:TypeError:Cannot read properties of undefined(reading ‘ipconfig‘)問題
- 解決ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many問題
相關(guān)文章
MySQL數(shù)據(jù)庫存儲引擎和分支現(xiàn)狀分析
在MySQL經(jīng)歷了2008年Sun的收購和2009年Oracle收購Sun的過程中,基本處于停滯發(fā)展的情況,在可以預(yù)見的未來,MySQL是肯定會被Oracle擱置并且逐步雪藏消滅掉的。2011-03-03