Home  >  Article  >  Database  >  How to solve the problem that localhost cannot connect to the local mysql database

How to solve the problem that localhost cannot connect to the local mysql database

黄舟
黄舟Original
2017-08-10 15:22:025126browse

In some programs, it is often necessary to connect to a local database to test the program. Sometimes the mysql database cannot be connected using localhost, but the link can be successful using 127.0.0.1. For the convenience of testing, the computer needs to be properly configured. Configure so that localhost can also successfully connect to the mysql database.

1. First use Navicat for MySQL to create a database locally.

How to solve the problem that localhost cannot connect to the local mysql database


## 2. Create a PHP in dreamweaver Formatted web pages to facilitate link testing.

How to solve the problem that localhost cannot connect to the local mysql database


##3. The test found that if it cannot be used When localhost connects to the mysql database, an error message will be prompted

How to solve the problem that localhost cannot connect to the local mysql database

4. If the third step occurs, you need to modify C :\Windows\System32\drivers\etc directory hosts file.

How to solve the problem that localhost cannot connect to the local mysql database


##5. Open hosts with notepad,

Find the line 127.0.0.1 localhost, delete the "#" in this line, and save it.

If there is no such line, add it manually.

How to solve the problem that localhost cannot connect to the local mysql database


##6. After saving, before using again Web page test,

At this time, you can connect the local mysql database through localhost

How to solve the problem that localhost cannot connect to the local mysql database



##

The above is the detailed content of How to solve the problem that localhost cannot connect to the local mysql 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