mysql安裝後,一直是穩定運行,可是忽然今天就掛了,啓動不了。mysql
我對mac下mysql的目錄又極其不熟,網上的教程有不少,關於mysql目錄的位置也是五花八門,致使如此的緣由多是由於
每一個人使用了不一樣的安裝方式。sql
我出現的錯誤是
sudo /usr/local/var/mysql/mysql.server start(經過系統的mysql啓動也不行)
Error!The server quit without updating PID file (/usr/local/var/mysql/MyMacBook-Pro.local.pid)app
只說個人解決方式,照搬可能不適用dom
cd /usr/local/var/dataui
查找.err的文件,mac在這個目錄下有不少err結尾的文件,一個個查。個人是這個:MyMacBook-Pro.local.erratom
這個文件中包含了錯誤輸出:spa
2018-04-09 14:44:02 2860 [Note] Plugin 'FEDERATED' is disabled. 2018-04-09 14:44:02 2860 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-04-09 14:44:02 2860 [Note] InnoDB: The InnoDB memory heap is disabled 2018-04-09 14:44:02 2860 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-04-09 14:44:02 2860 [Note] InnoDB: Memory barrier is not used 2018-04-09 14:44:02 2860 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-04-09 14:44:02 2860 [Note] InnoDB: Using CPU crc32 instructions 2018-04-09 14:44:02 2860 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2018-04-09 14:44:02 2860 [Note] InnoDB: Completed initialization of buffer pool 2018-04-09 14:44:02 2860 [Note] InnoDB: Highest supported file format is Barracuda. 2018-04-09 14:44:02 2860 [Note] InnoDB: The log sequence numbers 2462362688 and 2462362688 in ibdata files do not match the log sequence number 2462758734 in the ib_logfiles! 2018-04-09 14:44:02 2860 [Note] InnoDB: Database was not shutdown normally! 2018-04-09 14:44:02 2860 [Note] InnoDB: Starting crash recovery. 2018-04-09 14:44:02 2860 [Note] InnoDB: Reading tablespace information from the .ibd files... 2018-04-09 14:44:02 7fff9506e3c0 InnoDB: Operating system error number 13 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory InnoDB: Error: could not open single-table tablespace file ./db_hello/email_domain.ibd InnoDB: We do not continue the crash recovery, because the table may become InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it. InnoDB: To fix the problem and start mysqld: InnoDB: 1) If there is a permission problem in the file and mysqld cannot InnoDB: open the file, you should modify the permissions. InnoDB: 2) If the table is not needed, or you can restore it from a backup, InnoDB: then you can remove the .ibd file, and InnoDB will do a normal InnoDB: crash recovery and ignore that table. InnoDB: 3) If the file system or the disk is broken, and you cannot remove InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf InnoDB: and force InnoDB to continue crash recovery here.
包含了一大坨,沒辦法,只能一句句的啃了,跟吃屎同樣。rest
InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory. InnoDB: Error: could not open single-table tablespace file ./db_hello/email_domain.ibd
這句話已經把啓動失敗的緣由交代的很清楚了。code
對,就是它,沒權限,至於運行好好的,忽然一個表的權限變了,很誠懇的說,我也不曉得orm
查看了下db_hello下email_domian.ibd的權限
-rwxr-xr-x@ 1 root _mysql 98304 2 8 15:11 email_domain.ibd
變成了root,md,還特麼帶了一個@符號(表文件擴展的意思,可用ls -l@ email_domain.ibd查詢擴展信息)
改用戶到_mysql
chown _mysql:_mysql email_domain.ibd
保存,從新啓動,成功
清淨了