ubuntu – mysql:在unix socket上绑定:权限被拒绝

前端之家收集整理的这篇文章主要介绍了ubuntu – mysql:在unix socket上绑定:权限被拒绝前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
无法启动 mysql
sudo /usr/bin/MysqLd_safe  --datadir=/srv/MysqL/myDB --log-error=/srv/MysqL/logs/MysqLd-myDB.log --pid-file=/srv/MysqL/pids/MysqLd-myDB.pid --user=MysqL  --socket=/srv/MysqL/sockets/MysqL-myDB.sock --port=3700


120222 13:40:48 MysqLd_safe Starting MysqLd daemon with databases from /srv/MysqL/myDB
120222 13:40:54 MysqLd_safe MysqLd from pid file /srv/MysqL/pids/MysqLd-myDB.pid ended

/srv/MysqL/logs/MysqLd-myDB.log:@H_404_4@

120222 13:43:53 MysqLd_safe Starting MysqLd daemon with databases from /srv/MysqL/myDB
120222 13:43:53 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/MysqLd: Table 'plugin' is read only
120222 13:43:53 [ERROR] Can't open the MysqL.plugin table. Please run MysqL_upgrade to create it.
120222 13:43:53  InnoDB: Completed initialization of buffer pool
120222 13:43:53  InnoDB: Started; log sequence number 32 4232720908
120222 13:43:53 [ERROR] Can't start server : Bind on unix socket: Permission denied
120222 13:43:53 [ERROR] Do you already have another MysqLd server running on socket: /srv/MysqL/sockets/MysqL-myDB.sock ?
120222 13:43:53 [ERROR] Aborting

120222 13:43:53  InnoDB: Starting shutdown...

一个实例MysqLd正在运行:@H_404_4@

$ps aux | grep MysqL
MysqL     1093  0.0  0.2 169972 18700 ?        Ssl  11:50   0:02 /usr/sbin/MysqLd
$

港口3700可用:@H_404_4@

$netstat -a | grep 3700
$

套接字的目录为空:@H_404_4@

$ls /srv/MysqL/sockets/
$

有所有权限:@H_404_4@

$ls -l /srv/MysqL/
total 20
drwxrwxrwx  2 MysqL MysqL 4096 2012-02-22 13:28 logs
drwxrwxrwx 13 MysqL MysqL 4096 2012-02-22 13:44 myDB
drwxrwxrwx  2 MysqL MysqL 4096 2012-02-22 12:55 pids
drwxrwxrwx  2 MysqL MysqL 4096 2012-02-22 12:55 sockets
drwxrwxrwx  2 MysqL MysqL 4096 2012-02-22 13:25 version

Apparmor配置:@H_404_4@

$cat /etc/apparmor.d/usr.sbin.MysqLd
# vim:Syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>

/usr/sbin/MysqLd flags=(complain) {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/user-tmp>
  #include <abstractions/MysqL>
  #include <abstractions/winbind>

  capability dac_override,capability sys_resource,capability setgid,capability setuid,network tcp,/etc/hosts.allow r,/etc/hosts.deny r,/etc/MysqL/*.pem r,/etc/MysqL/conf.d/ r,/etc/MysqL/conf.d/* r,/etc/MysqL/*.cnf r,/usr/lib/MysqL/plugin/ r,/usr/lib/MysqL/plugin/*.so* mr,/usr/sbin/MysqLd mr,/usr/share/MysqL/** r,/var/log/MysqL.log rw,/var/log/MysqL.err rw,/var/lib/MysqL/ r,/var/lib/MysqL/** rwk,/var/log/MysqL/ r,/var/log/MysqL/* rw,/{,var/}run/MysqLd/MysqLd.pid w,var/}run/MysqLd/MysqLd.sock w,/srv/MysqL/ r,/srv/MysqL/** rwk,/sys/devices/system/cpu/ r,# Site-specific additions and overrides. See local/README for details.
  #include <local/usr.sbin.MysqLd>
}

有什么建议?@H_404_4@

UPD1:@H_404_4@

$touch /srv/MysqL/sockets/MysqL-myDB.sock
$sudo chown MysqL:MysqL /srv/MysqL/sockets/MysqL-myDB.sock
$ls -l /srv/MysqL/sockets/MysqL-myDB.sock
-rw-rw-r-- 1 MysqL MysqL 0 2012-02-22 14:29 /srv/MysqL/sockets/MysqL-myDB.sock
$sudo /usr/bin/MysqLd_safe --datadir=/srv/MysqL/myDB --log-error=/srv/MysqL/logs/MysqLd-myDB.log --pid-file=/srv/MysqL/pids/MysqLd-myDB.pid --user=MysqL --socket=/srv/MysqL/sockets/MysqL-myDB.sock --port=3700
120222 14:30:18 MysqLd_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
120222 14:30:18 MysqLd_safe Logging to '/srv/MysqL/logs/MysqLd-myDB.log'.
120222 14:30:18 MysqLd_safe Starting MysqLd daemon with databases from /srv/MysqLmyDB
120222 14:30:24 MysqLd_safe MysqLd from pid file /srv/MysqL/pids/MysqLd-myDB.pid ended
$ls -l /srv/MysqL/sockets/MysqL-myDB.sock
ls: cannot access /srv/MysqL/sockets/MysqL-myDB.sock: No such file or directory
$

UPD2:@H_404_4@

$sudo netstat -lnp | grep MysqL
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1093/MysqLd
unix  2      [ ACC ]     STREAM     LISTENING     5912     1093/MysqLd         /var/run/MysqLd/MysqLd.sock

$sudo lsof | grep /srv/MysqL/sockets/MysqL-myDB.sock
lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/sears/.gvfs
      Output information may be incomplete.

UPD3:@H_404_4@

$cat /etc/MysqL/my.cnf
#
# The MysqL database server configuration file.
#
# You can copy this to one of:
# - "/etc/MysqL/my.cnf" to set global options,# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.MysqL.com/doc/MysqL/en/server-system-variables.html

# This will be passed to all MysqL clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/MysqL/debian.cnf when changing the socket location.
[client]
port            = 3306
socket          = /var/run/MysqLd/MysqLd.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_MysqLd]. Both versions are currently parsed.
[MysqLd_safe]
socket          = /var/run/MysqLd/MysqLd.sock
nice            = 0

[MysqLd]
#
# * Basic Settings
#

#
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor,you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.MysqLd.
#

user            = MysqL
socket          = /var/run/MysqLd/MysqLd.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/MysqL
tmpdir          = /tmp
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/MysqL/MysqL.log
#general_log             = 1

log_error                = /var/log/MysqL/error.log

# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/MysqL/MysqL-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave,see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/MysqL/MysqL-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/MysqL/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual,too,if you want chroot!
# chroot = /var/lib/MysqL/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/MysqL/cacert.pem
# ssl-cert=/etc/MysqL/server-cert.pem
# ssl-key=/etc/MysqL/server-key.pem



[MysqLdump]
quick
quote-names
max_allowed_packet      = 16M

[MysqL]
#no-auto-rehash # faster start of MysqL but no tab completition

[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf',otherwise they'll be ignored.
#
!includedir /etc/MysqL/conf.d/
Can't start server : Bind on unix socket: Permission denied
Do you already have another MysqLd server running on socket: /srv/MysqL/sockets/MysqL-myDB.sock ?

看起来像AppArmor是罪魁祸首.尝试改变这个:@H_404_4@

/{,

至:@H_404_4@

/srv/MysqL/pids/MysqLd-myDB.pid w,/srv/MysqL/sockets/MysqL-myDB.sock w,
原文链接:/ubuntu/347789.html

猜你在找的Ubuntu相关文章