Solve the problem that php cannot connect to the mysql (PerconaServer) database through localhost and connect to the mysql database through ip addresses such as 127.0.0.1. problem occurred when using the online generation tool on the PerconaServer website generated my. cnf configuration file. php cannot connect to the mysql database through localhost after the right-side configuration is enabled. however
Solve the problem that php cannot connect to the mysql (Percona Server) database through localhost and can connect to the mysql database through ip addresses such as 127.0.0.1. problem occurred when using the online generation tool on the official website of Percona Server to generate my. cnf configuration file. php cannot connect to the mysql database through localhost after the right-side configuration is enabled. however
Solve the problem that php cannot connect to the mysql (Percona Server) database through localhost and can connect to the mysql database through ip addresses such as 127.0.0.1.
Problem generation
The my. cnf configuration file is generated by using the online generation tool on the Percona Server website. After the right and right configurations are configured and OK is enabled, php cannot connect to the mysql database through localhost.
However, it can be connected through an IP address.
Differences between localhost and 127.0.0.1 of mysql
What does localhost use? Unix? Sock
What does 127.0.0.1 go through? Tcp
Cause Analysis
The problem that the localhost cannot be connected is that mysql is used in php by default? Unix? What does sock use? /Tmp/mysql. sock
If you have modified the sock path of mysql, you must specify it in php. ini.
Solve the problem
So: How does php connect to mysql? Localhost cannot be connected. ip addresses such as 127.0.0.1 can be connected.
1. modify the configuration in php. ini and specify the mysql. sock location.
Or
2. modify my. cnf configuration ?? /Tmp/mysql. sock
Zemanta
Original article address: solve the problem that php cannot connect to the mysql database through localhost. Thank you for sharing it with the original author.