How To Fix Apache Cannot Connect To Mysql Server Tutorial

Home > Connect To > Apache Cannot Connect To Mysql Server

Apache Cannot Connect To Mysql Server

Contents

Back to top My problem I just ran into this problem on a new server I'm using with A2 Hosting, where the exact error I got in my PHP MySQL program First, you can change your host string to "127.0.0.1", like this: $host = '127.0.0.1'; By using an IP address like this instead of the string "localhost", MySQL automatically won't try to mysql_error()); } mysql_select_db ($database); Back to top MySQL socket error - Solution #1 The short story is that there are at least two possible solutions to this MySQL socket error problem. Just ping localhost or this IP address from the command line, and you'll see that they are the same. check over here

This second solution raises the question, "What is my MySQL socket file location?" Back to top Finding your MySQL socket file location The way I determined my MySQL socket file location I get this error message when trying to connect to my MySQL database from a PHP application. My PHP MySQL database connection code initially looked like this: $username = 'myusername'; $password = 'mypassword'; $host = 'localhost'; $database = 'mydatabase'; # connect to the database or die $link = If you're not familiar with this approach, the term "localhost" and the IP address 127.0.0.1 are synonymous.

Can't Connect To Mysql Server On (13)

Last updated: June 3 2016 Table of Contents My problem My PHP MySQL database properties MySQL socket error - Solution #1 MySQL mysql_connect socket error - Solution #2 Finding your MySQL socket alvin alexander my book at amazon   categories alaska (25) android (138) best practices (63) career (50) colorado (21) cvs (27) design (33) drupal (120) eclipse (6) funny (3) gadgets (108) git (15) intellij (4) What can I do to fix this? Back to top MySQL mysql_connect socket error - Solution #2 The second possible solution is to change your host to specify the MySQL socket file location, like this: $host = 'localhost:/tmp/mysql.sock'; I