已经从这里直接从stackoverflow这里,重新发布的问题,并添加my.cnf在一个post的结尾。
到目前为止,在我十多年的linux经验中,我遇到过的所有权限问题已经用chmod -R 777 /path/where/the/problem/has/occured (每一个谎言都有一个真理在里面 :)
这一招不起作用,所以我转向你寻求帮助。 我从头开始用zc.buildout(www。buildout。org)编译mysql服务器。 我通过执行/home/toinbis/.../parts/mysql/bin/mysqld_safe启动它,这个工程。 问题是,我将从supervisor(supervisord。org)脚本内部启动该脚本,并且在部署服务器上使用时,需要使用root权限启动它(以便使用相同的脚本启动nginx服务器,将有权访问80端口)。 问题是, sudo /home/toinbis/.../parts/mysql/bin/mysqld_safe ,失败,生成错误,张贴在下面的错误日志(Apache和Nginx的预期工作)。
http://lists.mysql.com/mysql/216045build议,“有两个错误:一个缺less的表和mysqld无法访问的文件系统”。 mysqldatadir和所有的mysql服务器二进制文件有777的权限,talbe mysql.plugin确实存在并且有777权限(为什么Can't open the mysql.plugin table ?),“sudo touch mysql_datadir / tmp / file”会创build文件Can't create/write to file /home/toinbis/.../runtime/mysql_datadir/tmp/ib4e9Huz ?)。
chgrp -R mysql mysql_datadir并添加“root,toinbis,mysql”用户到mysql组( cat /etc/group | grep mysql输出mysql:x:124:root,toinbis,mysql )没有效果 – 当我启动它时随便的用户,它开始时,作为一个根 – 它失败。 是否MySQL服务器,甚至开始作为根,试图作为其他操作,比方说,'MySQL'用户? 但即使在这种情况下,将mysql用户添加到mysql组,并使所有mysql_datadirs文件属于mysql组应该使事情顺利进行。
我知道,简单地以root和mysql启动一个nginx可能是一个好主意 – 就像一个用户一样,但是这个错误激怒了我,所以投入了足够的精力,所以不仅仅是“使事情有效”,而是也使事情完全按照我最初想要的那样工作,所以要有可能的概念certificate。
这是生成的错误:
091213 20:02:55 mysqld_safe Starting mysqld daemon with databases from /home/toinbis/.../runtime/mysql_datadir /home/toinbis/.../parts/mysql/libexec/mysqld: Table 'plugin' is read only 091213 20:02:55 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. /home/toinbis/.../parts/mysql/libexec/mysqld: Can't create/write to file '/home/toinbis/.../runtime/mysql_datadir/tmp/ib4e9Huz' (Errcode: 13) 091213 20:02:55 InnoDB: Error: unable to create temporary file; errno: 13 091213 20:02:55 [ERROR] Plugin 'InnoDB' init function returned error. 091213 20:02:55 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 091213 20:02:55 [ERROR] Can't start server : Bind on unix socket: Permission denied 091213 20:02:55 [ERROR] Do you already have another mysqld server running on socket: /home/toinbis/.../runtime/var/pids/mysql.sock ? 091213 20:02:55 [ERROR] Aborting 091213 20:02:55 [Note] /home/toinbis/.../parts/mysql/libexec/mysqld: Shutdown complete 091213 20:02:55 mysqld_safe mysqld from pid file /home/toinbis/.../runtime/var/pids/mysql.pid ended
我my.cnf(基本和数据目录(包括tempdir)有chmod -R 777 permissions ):
[client] socket = /home/toinbis/.../runtime/var/pids/mysql.sock port = 8002 [mysqld_safe] socket = /home/toinbis/.../runtime/var/pids/mysql.sock nice = 0 [mysqld] # # * Basic Settings # socket = /home/toinbis/.../runtime/var/pids/mysql.sock port = 8002 pid-file = /home/toinbis/.../runtime/var/pids/mysql.pid basedir = /home/toinbis/.../parts/mysql datadir = /home/toinbis/.../runtime/mysql_datadir tmpdir = /home/toinbis/.../runtime/mysql_datadir/tmp skip-external-locking bind-address = 127.0.0.1 log-error =/home/toinbis/.../runtime/logs/mysql_errorlog # # * Fine Tuning # key_buffer = 16M max_allowed_packet = 32M thread_stack = 128K thread_cache_size = 8 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. #log = /home/toinbis/.../runtime/logs/mysql_logs/mysql.log # # Error logging goes to syslog. This is a Debian improvement :) # # Here you can see queries with especially long duration #log_slow_queries = /home/toinbis/.../runtime/logs/mysql_logs/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. #server-id = 1 #log_bin = /home/toinbis/.../runtime/mysql_datadir/mysql-bin.log #binlog_format = ROW #read_only = 0 #expire_logs_days = 10 #max_binlog_size = 100M #sync_binlog = 1 #binlog_do_db = include_database_name #binlog_ignore_db = include_database_name # # * InnoDB # innodb_data_file_path = ibdata1:10M:autoextend innodb_buffer_pool_size=64M innodb_log_file_size=16M innodb_log_buffer_size=8M innodb_flush_log_at_trx_commit=1 innodb_file_per_table innodb_locks_unsafe_for_binlog=1 [mysqldump] quick quote-names max_allowed_packet = 32M [mysql] #no-auto-rehash # faster start of mysql but no tab completion [isamchk] key_buffer = 16M
任何想法非常感谢!
问候,
至
PS抱歉杂乱的超链接,这是我的第一篇文章和反垃圾邮件function的SF不允许正确发布:)
首先? 不要使用777。 别。 守护进程不会以root身份运行(如果任何人有缓冲区溢出,如果有人设法通过SQL注入或其他方式进入您的网站,他们刚刚植根于您的框),这是一个巨大的安全问题。 在打开端口后使用包装脚本来删除权限。 Nginx不需要以root身份运行。
其次,你的问题似乎是path。 不是权限。 除非你在本文中用/.../replace了实际path,否则这是你的问题。 如果你这样做,请用完整path更新问题。
愚蠢的问题第一。 你确定没有其他的mysql正在运行吗? 尽pipe权限合理(尽pipe777)只读错误几乎总是一个标志,文件被另一个进程locking。 你可以使用lsof来查明是否有其他东西在搞乱你的文件:
$ lsof /home/toinbis/.../runtime/var/pids/mysql.sock
要么
$ sudo lsof | grep mysqld
如果你仍然得到错误尝试上述,如果他们是任何匹配,他们是什么责怪。
如果不这样做,请重新构build,永远不要以非root用户身份启动。 这有什么区别?
如果你想欺骗,使用buildout_script( http://pypi.python.org/pypi/buildout_script/0.2a1 )创build一个包装脚本,
它需要一个模板如下所示:
#! /bin/sh sudo -u mysql_or_your_username_here {buildout[bin-directory]}/mysqld_safe $@
这样mysqld_safe永远不会以root身份运行,并且避免了这个错误。 我觉得这很讨厌,但你的整个设置已经是我永远不会做的事情,所以我认为这将是一个很好的公司! 🙂
我相信Gentoo和像puppet,chef-solo或者kokki这样的系统级configuration工具虽然会更适合你。
你的主目录是跨NFS安装的,挂载的是将root权限压缩到“nobody”的configuration文件? 如果是这样,请以另一个用户身份启动,或者不要将数据存储在NFS中,或者不使用root_squash导出NFS共享。
我从头开始用zc.buildout(www。buildout。org)编译mysql服务器。
看起来你陷入了混乱! 🙂
为什么你要从源代码编译MySQL服务器有一个特定的原因吗? 我发现这个MySQL“构build”脚本 ,这可能与你在做什么有关:似乎下载MySQL服务器和一个软件包,以支持Python的MySQL,然后编译和安装在非标准的位置。
无论如何,MySQL特别build议不要从源代码编译,因为它们为各种不同的平台提供了自己的优化二进制包。
如果你正在部署一个很好的包pipe理系统,那么你的“buildout”脚本只需要调用目标系统的包pipe理器。 这将给你一个供应商build议和批准的安装(没有chmod -R 777必要!)在几个命令。 对于RHEL / CentOS系统,程序大致是:
yum install mysql-server (MySQL-python?) [edit /etc/my.cnf] chkconfig mysqld on && service mysqld start [lock down the server by adjusting the grants]
看看是多么容易,可重复的是:)。 除非你有一个很好的理由,否则与非标准安装位置和chmod -R 777游戏相比,使用系统的内置包pipe理是绝对可取的。