In Linux, MySQL cannot be started normally.

Source: Internet
Author: User
Recently, MySQL databases were used in the company's projects. The system version is CentOS5.1i386. After installation, you cannot use quot; servicemysqlstartquot;

Recently, MySQL database was used in the company's project. The system version is CentOS 5.1 i386. After the installation is complete, you cannot use quot; service mysql startquot;

Recently, MySQL database was used in the company's project. The system version is CentOS 5.1 i386.

After the installation is complete, "service mysql start" cannot be enabled properly. Run the mysqld_safe program manually. The error message is ".../etc/rc. d/init. d/mysql 159: kill (xxxx) no such process ". I searched the internet and many people solved the problem, but I did not see detailed explanations and analysis of the cause of the error. I read the MySQL instruction document and found the problem. This error message indicates that the mysqld_safe program failed to start. Although a process cannot be killed, the kill command is used to test whether the specified process still exists.

When an error occurs, you must check the following:

1. Whether selinux is disabled.

2. If you use the default installation method, check whether the user "mysql" has been created.

3. Check whether the datadir directory in the mysql configuration information has been created (Use this command to view the configured datadir: mysqld -- verbose -- help | grep datadir ).

4. Whether the owner of the datadir directory is the same as that in the mysqld_safe command line option (the default value is "mysql ).

Error Cause Analysis:

1. After installing the MySQL-server-xxxx.rpm using the RPM package, you will see the above error shown in the terminal, MySQL failed to enable. In this case, the cause of the failure is that selinux is enabled, selinux is disabled (google for details), and the system is restarted. Generally, the problem can be solved. I tried again in my VM just now.

2. When you use the rpm package for installation, the "mysql" user is automatically created. However, in some "trusted operating systems", the root user is not authorized to add new users, resulting in errors. In this case, you can manually add a "mysql" account and set the password as needed. If you can only use the root user, you can make the following changes in my. cnf (this file will be introduced below:

[Mysqld]

User = root # or other user names that can be used

The "root" is the System user specified in the command line when the mysqld_safe program is called in the script.

3. After installing the MySQL-server-xxxx.rpm, it is displayed as normal, but modified my. cnf (the original file is the my-xxxx.cnf file in/usr/share/mysql/, You need to select the appropriate file to copy to the/etc/directory, and renamed my. cnf) file. The cause of this error is probably because you did not call the mysql_install_db function. This function is used to create the basic mysql database, such as the user information, and use my. cnf configures mysql, such as the database directory (datadir) and root directory (basedir. In the current system, the default datadir is/var/lib/mysql /.

4. When the rpm package is used for installation, the mysql_install_db function is called by default, but the configuration information is also the default. After modifying the my. cnf file, you need to re-call the "mysql_install_db -- user = mysql" command to configure the database according to the new configuration file. The "-- user = mysql" option enables the creator and owner of the created datadir to be a mysql user (this user is automatically created when the rpm package is installed ). This option must be added if other users are not specified for mysqld_safe.

Refer to the above method to solve the problem that MySQL cannot be started normally. Systems other than CentOS 5.1 are not tested.

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.