Solve the problem that MySQL cannot be started on centos.

Source: Internet
Author: User

1./etc/My. CNF Default Configuration

The configuration file is as follows:

[Mysqld]

Datadir =/var/lib/MySQL

Socket =/var/lib/MySQL. Sock

# Default
To using old password format for compatibility with MySQL 3.x

# Clients
(Those using the mysqlclient10 compatibility package ).

Old_passwords = 1

[Mysql. Server]

User = MySQL

Basedir =/var/lib

[Mysqld_safe]

Log-error =/var/log/mysqld. Log

PID-file =/var/run/mysqld. PID

 

Because the project needs to modify the value of datadir, as follows:

Datadir =/usr/local/project/etc/Data

 

Start MySql in centos:

[Wzhwho @ local ~] # Service
Mysqld start

Starting mysqld daemon [failed]

 

2. Check the error log first.

The default path for MySQL Log files installed with RPM is/var/log/mysqld. log.

Mysqld started

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/usr/local/project/etc/data/ibdata1

InnoDB: File Operation call: 'create '.

InnoDB: cannot continue operation.

Mysqld ended

 

The log shows that the MySQL data file directory does not have the permission, therefore, I need to set the permission and owner for the/usr/local/project/etc/DATA DIRECTORY according to the permission of the/var/lib/MySQL directory.

[Wzhwho @ local ~] # Ll
/Var/lib

Drwxr-X-r-x 1 MySQL
4
Apr 11
2009
MySQL

[Wzhwho @ local ~] # Ll
/Var/lib

[Wzhwho @ local ~] Chown-r MYSQL: MySQL/usr/local/project/etc/Data

[Wzhwho @ local ~] Chmod-r 755/usr/local/project/etc/Data

[Wzhwho @ local ~] # Ll
/Usr/local/project/etc

Drwxr-X-r-x 1 MySQL
4
Apr 11
2009
Data

Then I started MySQL again, but it still failed with the same log information.

 

3. modify the configuration file/etc/SELinux/config

Finally, I found such a reply in an email from a foreign friend:

If you are using SE Linux, set it
Permissive mode by editing/etc/SELinux/config

And changing

SELinux = enforcing
To SELinux = permissive

This solved all of my problems with

"Operating System error number 13 in a file operation" error

 

Therefore, if SELinux is the final issue, enter the command LS-Z and you will find the tag on the file or folder. If a file is created when SELinux is opened, even if SELinux is disabled, its permission control still works. You can use chcon to change permissions.

 

4. MySQL is successfully started.

[Wzhwho @ local ~] # Service
Mysqld start

Starting mysqld daemon [OK]

 

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.