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.
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
<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 authorizechown -R mysql.mysql /data/mysql
cd /data/mysql touch node1.pid
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 permissionsQuestion 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
basedir datadir
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
<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*
<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
Related free learning recommendations:
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!