Mysqld startup error after mysql modifies Directory

Source: Internet
Author: User
Tags socket syslog dmesg


Starting a mysql instance on a ubuntu testing machine should have been a simple task, but an error was reported during startup:

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
View error logs/var/log/mysql/error3307.log

The ibdata file cannot be created due to permission issues:
 

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
InnoDB: the directory.
InnoDB: File name./ibdata1
InnoDB: File operation call: 'create '.
InnoDB: Cannot continue operation.

In theory, you should have read and write permissions to view the directory:

Ls-ld/var/lib/mysql3307 drwx -- 4 mysql 4096 Feb 18/var/lib/mysql3307

Is there any other permission restriction?

Use dmesg to check whether there are some errors,

[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

View the configuration of/usr/sbin/mysqld:

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

Add the permission for the mysql3307 directory and restart apparmor:

/Var/lib/mysql3307/r,
/Var/lib/mysql3307/** rwk,
/Etc/init. d/apparmor restart

Restart mysqld again and report an error. However, the error message is different:

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 can also see the error message:

[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
Add configuration to/etc/apparmor. d/usr. sbin. mysqld and restart apparmor.
/Var/run/mysqld/mysqld3307.pid rw,
/Var/run/mysqld/mysqld3307.sock w,
/Run/mysqld/mysqld3307.pid rw,
/Run/mysqld/mysqld3307.sock w,

Restart mysqld again or report an error, but this time it is a new error:

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
Run mysql_install_db-defaults-file =/etc/mysql/my3307.cnf
This time, mysqld can be started properly:
160218 14:44:59 [Note] Server socket created on IP: '0. 0.0.0 '.
160218 14:44:59 [Note] Event schedents: 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.