mysql 修改目录后mysqld启动报错

在一台ubuntu测试机器上启动一个mysql实例,本来应该是一件很简单的事情,启动的时候却报错了:

mysqld_safe --defaults-file=/etc/mysql/my3307.cnf
160218 15:45:13 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.
160218 15:45:13 mysqld_safe Logging to '/var/log/mysql/error3307.log'.
160218 15:45:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql3307
160218 15:45:15 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld3307.pid ended
查看错误日志/var/log/mysql/error3307.log

发现是由于权限问题无法创建ibdata文件:
 

160218 12:19:09 InnoDB: Completed initialization of buffer pool
160218 12:19:09  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: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

查看目录,理论上应该有读写权限的啊:

ls -ld /var/lib/mysql3307 drwx—— 4 mysql mysql 4096 Feb 18 15:09 /var/lib/mysql3307

难道还有其它什么权限限制?

用dmesg看一下,确实有一些报错,

[4489099.208660] type=1400 audit(1455768562.142:57): apparmor="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/var/lib/mysql3307/ibdata1" pid=19775 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=105 ouid=105

查看/usr/sbin/mysqld的配置:

vi /etc/apparmor.d/usr.sbin.mysqld

增加mysql3307目录的权限,重启apparmor:

 /var/lib/mysql3307/ r,
 /var/lib/mysql3307/** rwk,
/etc/init.d/apparmor restart

再次重新启动mysqld,发现还是报错,不过这次报错的信息不一样了:

160218 12:44:03 [ERROR] Can't start server : Bind on unix socket: Permission denied
160218 12:44:03 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld3307.sock ?
160218 12:44:03 [ERROR] Aborting

dmesg也能看到错误消息:

[4491181.040673] type=1400 audit(1455770643.975:99): apparmor=”DENIED” operation=”mknod” profile=”/usr/sbin/mysqld” name=”/run/mysqld/mysqld3307.sock” pid=24093 comm=”mysqld” requested_mask=”c” denied_mask=”c” fsuid=105 ouid=105
到/etc/apparmor.d/usr.sbin.mysqld增加配置,重启apparmor
 /var/run/mysqld/mysqld3307.pid rw,
 /var/run/mysqld/mysqld3307.sock w,
 /run/mysqld/mysqld3307.pid rw,
 /run/mysqld/mysqld3307.sock w,

再次重启mysqld,还是报错,不过这次是新的报错:

160218 12:57:27 [Note] Server socket created on IP: '0.0.0.0'.
160218 12:57:27 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
160218 12:57:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld3307.pid ended
跑一下mysql_install_db –defaults-file=/etc/mysql/my3307.cnf
这次mysqld终于可以正常启动了:
160218 14:44:59 [Note] Server socket created on IP: '0.0.0.0'.
160218 14:44:59 [Note] Event Scheduler: Loaded 0 events
160218 14:44:59 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.46-0ubuntu0.14.04.2'  socket: '/var/run/mysqld/mysqld3307.sock'  port: 3307  (Ubuntu)

时间: 2024-09-27 01:58:09

mysql 修改目录后mysqld启动报错的相关文章

把activemq.xml文件更改为mysql持久化之后就会启动报错是怎么回事呢?

问题描述 把activemq.xml文件更改为mysql持久化之后就会启动报错是怎么回事呢? 在弄activemq持久化的,我把activemq.xml文件更改为mysql持久化之后就会启动报错是怎么回事呢?

asp-ASP.ascx 控件发布后,修改覆盖后 控件报错

问题描述 ASP.ascx 控件发布后,修改覆盖后 控件报错 ASP.net 的网站,我很多个页面引用了ascx格式的控件,并在后台 有与界面进行交互,发布完成,可以使用,但是根据需求更改了一个,有引用的界面发布之后,把界面覆盖了,并且把对应的DLL 也放到BIN里了 但是 报错找不到依赖,其他有引用的页面正常

为什么mysqld启动报错

在一台ubuntu测试机器上启动一个mysql实例,本来应该是一件很简单的事情, 启动的时候却报错了: mysqld_safe --defaults-file=/etc/mysql/my3307.cnf 160218 15:45:13 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take ef

安装Oracle JDK 7.0与8.0 for Mac OS X后Eclipse启动报错的解决之道

启动 Eclipse 时,直接报错The JVM shared library "/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib"does not contain the JNI_CreateJavaVM symbol. Unable to find any JVMs matching architecture "i386&qu

centos 7.x yum安装rabbitmq-server,启动报错解决方法

yum安装好rabbitmq-server后,启动报错 [root@openstack ~]# systemctl start rabbitmq-server.service Job for rabbitmq-server.service failed. See 'systemctl status rabbitmq-server.service' and 'journalctl -xn' for details. [root@openstack ~]# systemctl status rabb

MySQL 启动报错:File ./mysql-bin.index not found (Errcode: 13)_Mysql

Linux下安装初始化完MySQL数据库之后,使用mysqld_safe启动mysql数据库,如下发现,启动失败 [root@SVNServer bin]# ./mysqld_safe –user=mysql& 或 [root@SVNServer bin]# /etc/init.d/mysqld startStarting MySQL. ERROR! The server quit without updating PID file (/data/mysql/AY1402081609347760

修改 cassandra data commitlog cache路径,启动报错

修改配置文件:(因为var目空间比较小,data磁盘比较大) vi /etc/cassandra/conf/cassandra.yaml  把 /var/lib/cassandra/data/ 修改成 /data/cassandra/data/ 目录后拷贝文件 cp /var/lib/cassandra/  /data/ 启动报错: java.lang.AssertionError: Directory /data/cassandra/data is not accessible.      

安装完Nginx后启动报错

安装完Nginx之后,启动报错. [vagrant@localhost sbin]$ sudo ./nginx ./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory 执行ldd命令,找到Nginx的依赖共享库文件. vagrant@localhost sbin]$ ldd $(which /usr/local/ng

技术-关于用eclipse做gwt开发时,应用启动后,eclipse报错

问题描述 关于用eclipse做gwt开发时,应用启动后,eclipse报错 Could not stop source viewer server. java.lang.ExceptionInInitializerError at com.google.gdt.eclipse.platform.jetty.JettyServer.initLogging(JettyServer.java:40) at com.google.gdt.eclipse.platform.jetty.JettyServ