Home  >  Article  >  Database  >  Share a database connection failure problem and its solution

Share a database connection failure problem and its solution

零下一度
零下一度Original
2017-05-10 15:57:381687browse

Today a colleague said that his mysql database connection could not be reached. He was very depressed. The error was reported as follows

# /etc/init.d/mysql startStarting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/mysql3306/data/mysql.pid).

The first thing I thought of was to Look at the error log, the error log is as follows:

# vim error.log 
2017-05-04T13:35:17.965606Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Permission denied
2017-05-04T13:35:17.965643Z 0 [ERROR] Do you already have another mysqld server running on port: 1005 ?
2017-05-04T13:35:17.965674Z 0 [ERROR] Aborting

(1) The first reaction is insufficient permissions. After investigation, it is found that the user permissions are sufficient. The owner and group of the mysql data directory are mysql, so they are excluded;

(2) The second sentence of the error indicates that there may be a mysql service occupying port 1005, so the result of using the ss -nltup|grep mysql command is that there is no mysql service.

(3) Finally, I searched Baidu a lot, but to no avail. Suddenly I had an idea, does the port range of mysql include 1005? So I checked the manual and found the following:

--port=port_num
The port number that the server should use when listening for TCP/IP connections. The port number
must be 1024 or higher unless the server is started by the root system user.

The manual is very clear. The port range of mysql is greater than or equal to 1024. It took me so long to find out that the manual has been written to death a long time ago. It is really difficult. Please, just use the default port honestly and read the manual more.

【Related recommendations】

1. Free mysql online video tutorial

2. MySQL latest manual tutorial

3. Boolean Education Yan Shiba mysql introductory video tutorial

The above is the detailed content of Share a database connection failure problem and its solution. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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