一直使用好好的mysql命令,突然今天抽風,無論使用任何mysql選項都報“段錯誤 (core dumped)”,以為是mysqld程序出問題了,所以我嘗試重啟,因為我的環境上是多實例,用了mysqld_multi來管理,沒想到一敲mysqld_multi命令也報錯:
shell > /usr/local/mysql/bin/mysqld_multi stop 3306-3308
my_print_defaults: unknown option '-s'
my_print_defaults: unknown option '-s'
my_print_defaults: unknown option '-s'
my_print_defaults: unknown option '-s'
my_print_defaults: unknown option '-s'
這個-s選項是為了彌補5.6.x版本無法使用mysqld_multi命令stop實例的BUG而加的,之前用得好好的,突然這個也出問題了。
然后查看錯誤日志,沒有發現任何錯誤信息,查看系統日志,也沒發現什么有用信息
因為是測試環境,然后我直接把系統給reboot了,再次用mysql命令登錄,還是報:段錯誤 (core dumped)
接着我查看一下命令路徑:
shell > which mysql
/usr/bin/mysql
發現命令的路徑是/usr/bin/mysql,而之前的路徑是/usr/local/mysql/bin/mysql,估計是前兩天安裝一個依賴包的時候把yum的mysql包給安裝了,查看下:
shell > rpm -qf `which mysql`
mysql-5.1.73-5.el6_6.x86_64
果然是這樣,這里因為是測試環境,我就直接暴力一點cp /usr/local/mysql/bin下的命令覆蓋掉/usr/bin/下的mysql相關的命令:
\cp -ar /usr/local/mysql/bin/* /usr/bin/
然后再次使用mysql命令登錄,這次正常了:
[
root@localhost ~]# mysql
Logging to file '/data/mysql/query.log'
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@localhost Fri Jan 15 11:27:33 2016 11:27:33 [(none)]>
再試試mysqld_multi的停止與啟動,發現也正常了
注:因為是測試環境,所以想命令簡單點,偷個懶,沒有寫絕對路徑,沒想到踩坑了,線上環境還是建議使用絕對路徑
