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
f35d6e602fd7d0f0edfa6f7d103c1b57If 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
2cc198a1d5eb0d3eb508d858c9f5cbdbIf 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
##f35d6e602fd7d0f0edfa6f7d103c1b57Find the specified mysql data storage Directory and authorizechown -R mysql.mysql /data/mysql2cc198a1d5eb0d3eb508d858c9f5cbdbIf 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
Question 3: The my.cnf configuration file corresponding to the mysql is wrong
f35d6e602fd7d0f0edfa6f7d103c1b57 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
f35d6e602fd7d0f0edfa6f7d103c1b57When 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=33062cc198a1d5eb0d3eb508d858c9f5cbdbIf it can be started, you need to check the parameters in the mysql startup script or mysql.server configuration file and modify themFocus on the following two parameters
basedir datadir
Question 5: The mysql has residual data that affects the startup of the service##f35d6e602fd7d0f0edfa6f7d103c1b57Go to the data storage directory of mysql to delete it, and then restart
cd /data/mysql/ rm -r *index /etc/init.d/mysql start
2cc198a1d5eb0d3eb508d858c9f5cbdb 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*
5bdf4c78156c7953567bb5a0aef2fc53Remarks
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!