Why can't mysql create pid when starting?

coldplay.xixi
Release: 2023-01-04 09:36:08
Original
5369 people have browsed it

The reasons why pid cannot be created when mysql is started: 1. The port is occupied; 2. The directory mysql where the pid file is generated does not have enough permissions; 3. The my.cnf configuration file corresponding to the mysql is wrong; 4. The startup of mysql There is a problem with the script; 5. The mysql has residual data that affects the startup of the service.

Why can't mysql create pid when starting?

The operating environment of this tutorial: Windows 7 system, mysql version 8.0.22, DELL G3 computer.

The reason why pid cannot be created when mysql is started:

Problem 1: The port is occupied

<1>If you The port of the started mysql has been occupied by other services. You should modify the port number in the corresponding my.cnf to another port, and then restart mysql.

[mysqld] port=3307
Copy after login

<2>If the port number is already occupied before restarting mysql It is recommended to kill the mysql process and then restart it

Problem 2: The directory where the pid file is generated does not have enough permissions for mysql

##<1>Find the specified mysql data storage Directory and authorize

chown -R mysql.mysql /data/mysql
Copy after login

<2>If it is authorized, it still cannot be started. You can touch a pid file named after the host name yourself, and then start it

cd /data/mysql touch node1.pid
Copy after login

Question 3: The my.cnf configuration file corresponding to the mysql is wrong

<1> Check whether the port, datadir, basedir, socket and other parameters in my.cnf are configured correctly, and whether the configured directory mysql has permissions

Question 4: There is a problem with the mysql startup script

<1>When you are not sure whether the parameters in the startup script or mysql.server configuration file are normal, first use the mysqld_safe mode to start and check whether it can be started.

(First cd to the installation root of mysql Directory)

./mysqld_safe --defaults-file=/etc/mysql_3306/my.cnf --user=mysql or ./mysqld_safe --defaults-file=/etc/mysql/3306/my.cnf --basedir=/Apk/install/mysql --datadir =/mysql/data/ --pid-file=/mysql/data/mysql.pid --socket=/mysql/data/mysql.sock --port=3306
Copy after login

<2>If it can be started, you need to check the parameters in the mysql startup script or mysql.server configuration file and modify them

Focus on the following two parameters

basedir datadir
Copy after login

Question 5: The mysql has residual data that affects the startup of the service##<1>Go to the data storage directory of mysql to delete it, and then restart

cd /data/mysql/ rm -r *index /etc/init.d/mysql start
Copy after login

<2> If it still cannot be started, go to the data storage directory of mysql and delete it again, and then start

(If the database is not newly installed and the data is still in use, it is not recommended to delete the files starting with ib. If deleted Afterwards, use backup to restore the database)

cd /data/mysql/ rm -r *index rm -r ib*
Copy after login

<3>Remarks

If you delete all the files in the mysql data storage directory, you should initialize it again. After initialization, start.

For example:

/Apk/install/mysql/mysql-5.5.32/script/mysql_install_db --user=mysql --basedir=/Apk/install/mysql/mysql-5.5.32 --datadir=/Apk/data/mysql_3306/data --pid-file=/Apk/data/mysql_3306/data/mysql.pid --socket=/tmp/mysql_3306.sock --port=3306
Copy after login

Related free learning recommendations:

mysql video tutorial

The above is the detailed content of Why can't mysql create pid when starting?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!