Home  >  Article  >  Backend Development  >  What is the reason why PHP fails to connect to the database?

What is the reason why PHP fails to connect to the database?

青灯夜游
青灯夜游Original
2019-10-15 15:25:526171browse

Various business systems will encounter some problems during use. One of them is the inability to log in to the management software due to database connection failure. This is a very troublesome and common problem.

What is the reason why PHP fails to connect to the database?

General business systems use SQL databases. Here we summarize the reasons and solutions for SQL database connection failures:

Causes 1:

Login errors such as login account, password, server name, and database name result in inability to connect. This is relatively common. Carefully check whether the information filled in is correct. If it is filled in correctly, it can usually be solved.

Solution: When the software being used fails to connect to the database, it is usually a problem with the server name. Changing the server name can generally solve the problem. If the database is installed on this machine, the server name can be replaced by "." or "(local)"; if it is installed on another computer in the LAN, the IP address can be used as the server name.

Cause two:

If the SQL server is not installed correctly, the database connection will not be able to be connected; after the database is installed, if the SQL service manager does not start, You have to go to the service to open it.

Solution: If the SQL database fails to be installed successfully, when you reinstall it again, the installation may not be possible, prompting that there is an unfinished installation hang. The solution is: open the registry editor, find and delete the PendingFileRenameOperations project in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager.

If you change the Windows user name or password, the SQL Service Manager will not start. The solution is to go to the service in the control panel to modify the startup. Specifically: click Start-->Settings-->Control Panel-->Administrative Tools-->Services-->Find the MS SQL SERVER service-->right-click on it-->Properties-- >Login-->Modify the account and password for starting the service.

Reason 3:

The database cannot be connected due to permission issues. The solution is to detect the computer's security protection restrictions, SQL Server security settings, and operating system security restrictions.

Solution: You can temporarily turn off the firewall or anti-virus software to see if it is caused by the security settings of these software.

SQL Server Security Settings: Open Enterprise Manager--> Expand the SQL Server group--> Right-click the server name--> Click Properties--> In SQL Server Properties--> In Security, select "Authentication" as "In SQL Server and Windows";

If the SQL server uses a Windows XP system, when the workstation computer cannot connect to the database, you can Create an identical WINDOWS user account and password for each workstation

Cause four:

Cause: There is a fault in the network connection;

Solution: Maintenance Is there a fault in the network?

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of What is the reason why PHP fails to connect to the database?. 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