Solution to the problem that mysql cannot connect to localhost: 1. Check whether the IP address can be pinged; 2. Check whether the firewall allows port 3306. If not, set the port number to 3306; 3. Start the database Just run the command "net start mysql" to try to connect.
Recommendation: "mysql tutorial"
First method: Check whether the IP address can be pinged, if so Look at the second one
The second one: check whether the firewall allows port 3306, management tools--Advanced Security Firewall--inbound rules--new rule
Click on the port
Set the port number to 3306
Allow Connection - write whatever name you want, for example: allow inbound port 3306
Then the administrator runs the command prompt (win R) cmd
Start database net start mysql Then try to connect!
The above is the detailed content of What should I do if MySql cannot connect to the local address localhost?. For more information, please follow other related articles on the PHP Chinese website!