Solve the problem that mysql cannot be started in Centos.

Source: Internet
Author: User

When I first came to the company today, the developers told me that mysql could not be started. I only knew that he had restarted all the services on the test server. At that time, I was so angry, I want to give him 124. If you say you want to restart the service, you have to ask me. Now there is a problem, and you will find me. the problem still needs to be solved. check the disk space of the server, check the mysql configuration, and check the mysql log to find the problem, as shown in the figure.

It turns out that there is a problem with the table. After you find the development question, this table is backed up by him and cannot be deleted. The data on the server is the latest and has not been backed up yet, it's really a dog. Okay, you can only modify innodb_force_recovery according to the prompts in the log.
Ps:

Innodb_force_recovery affects the recovery of the entire InnoDB storage engine. the default value is 0, indicating that all recovery operations are performed when recovery is required. when an effective recovery operation is not available, mysql may fail to start and record the error log. innodb_force_recovery can be set to 1-6. A large number contains the effects of all the preceding numbers. when the set parameter value is greater than 0, select, create, and drop operations can be performed on the table, but insert, update, or delete operations are not allowed.

1 (srv_force_ignore_0000upt): ignore the checked UPT page.
2 (SRV_FORCE_NO_BACKGROUND): prevents the main thread from running. If the main thread needs to execute the full purge operation, crash may occur.
3 (SRV_FORCE_NO_TRX_UNDO): no transaction rollback is performed.
4 (SRV_FORCE_NO_IBUF_MERGE): Do not merge insert buffer operations.
5 (SRV_FORCE_NO_UNDO_LOG_SCAN): If you do not view redo logs, the InnoDB storage engine considers uncommitted transactions as committed.
6 (SRV_FORCE_NO_LOG_REDO): do not roll back.

The procedure is as follows:

The following two parameters are added to my. cnf:
Innodb_force_recovery = 6
Innodb_purge_thread = 0

Restart mysql
Service mysqld restart

After restart, perform logical export on the database immediately, set innodb_force_recovery to 0, innodb_purge_thread = 1, and recreate the database. in this way, the mysql problem is solved, and the mysql timed backup is also changed to one backup in the morning and one backup in the evening.

Problem 2: MySQL cannot be started on CentOS

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 to 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]

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.