Home > Database > Mysql Tutorial > 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

黄舟
Release: 2017-08-10 15:22:02
Original
5146 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template