Mysql

mysql。在 unix 套接字上綁定:權限被拒絕

  • April 11, 2021

無法啟動mysql:

130408 11:31:22 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/libexec/mysqld: Table 'plugin' is read only
130408 11:31:22 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130408 11:31:22  InnoDB: Initializing buffer pool, size = 8.0M
130408 11:31:22  InnoDB: Completed initialization of buffer pool
130408 11:31:23  InnoDB: Started; log sequence number 0 19514977
130408 11:31:23 [ERROR] Can't start server : Bind on unix socket: Permission denied
130408 11:31:23 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
130408 11:31:23 [ERROR] Aborting

130408 11:31:23  InnoDB: Starting shutdown...
130408 11:31:28  InnoDB: Shutdown completed; log sequence number 0 19514977
130408 11:31:28 [Note] /usr/libexec/mysqld: Shutdown complete
130408 11:31:28 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

另一個mysql沒有執行:

[root@triton667 etc]# ps ax | grep mysql
9195 pts/1    S+     0:00 grep mysql

我的.cnf:

   [mysqld]
   datadir=/var/lib/mysql
   socket=/var/lib/mysql/mysql.sock
   user=mysql
   tmpdir=/tmp
   # Disabling symbolic-links is recommended to prevent assorted security risks
   symbolic-links=0
   max_allowed_packet=256M

   [mysqld_safe]

   log-error=/var/log/mysqld.log
   pid-file=/var/run/mysqld/mysqld.pid

“/tmp”和“/var/lib/mysql”的權限是 777/

有什麼建議麼?

UPD1

[root@triton667 etc]# mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck with default connection arguments
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) trying to connect
FATAL ERROR: Upgrade failed

UPD2:plugin.MYD、plugin.MYI 和 plugin.frm 存在於 /var/lib/mysql/mysql/ 中。

埠 3306 上沒有任何執行。

mysql.sock 不存在。我嘗試自己創建它,但重新啟動後它被刪除。

安裝(所有 rw):

[root@triton667 mysql]# mount
/dev/md1 on / type ext4 (rw,noatime,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/md0 on /boot type ext2 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)

今天當我嘗試在子域上複製我的網站時出現了這個問題。

  1. 首先確保使用 rm 命令刪除現有的套接字文件。
rm /var/lib/mysql/mysql.sock
  1. 通過以下命令殺死所有現有的 MySQL 程序。
service mysql stop

3)非常重要:確保/var/lib/文件夾下MySQL數據庫目錄的權限應該是mysql:root

chown -R mysql:root /var/lib/mysql
  1. 有了以上資訊,你應該可以成功啟動MySQL,並且應該在數據庫目錄下成功創建socket文件。
service mysql start

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