Mysql

MySQL權限錯誤

  • May 19, 2019

似乎在 Ubuntu 14.04 機器上,使用者mysql無法訪問任何東西。它不是寫日誌也不是讀文件。見證:

- bruno():mysql$ cat /etc/passwd | grep mysql
mysql:x:116:127:MySQL Server,,,:/nonexistent:/bin/false

- bruno():mysql$ sudo mysql_install_db
Installing MySQL system tables...
140818 18:16:50 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
140818 18:16:50 [ERROR] Aborting
140818 18:16:50 [Note] 

Installation of system tables failed!  Examine the logs in
/var/lib/mysql for more information.

...boilerplate trimmed...

- bruno():mysql$ ls -la /usr/share/mysql/english/errmsg.sys
-rw-r--r-- 1 root root 59535 Jul 29 13:40 /usr/share/mysql/english/errmsg.sys
- bruno():mysql$ wc -l /usr/share/mysql/english/errmsg.sys
16 /usr/share/mysql/english/errmsg.sys

在這裡我們看到即使打開了權限也mysql無法讀取,實際上普通登錄使用者可以讀取文件(帶)。此外,MySQL 沒有寫入任何日誌:/usr/share/mysql/english/errmsg.sys``wc

- bruno():mysql$ ls -la /var/log/mysql
total 8
drwxr-s---  2 mysql adm    4096 Aug 18 16:10 .
drwxrwxr-x 18 root  syslog 4096 Aug 18 16:10 ..

什麼可能導致該使用者無法訪問任何內容?我能做些什麼呢?

mysql_install_db --no-defaults --basedir=<your base dir> --datadir=<your data dir> --language=<your language dir such as /usr/share/mysql/english/> --lc-messages-dir=<location>

請嘗試像上面一樣執行,並確保 mysql 對每個文件夾都有正確的權限。她的參考https://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.htmlhttps://dev.mysql.com/doc/refman/5.7/en/error-message -language.html

引用自:https://serverfault.com/questions/622221