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 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 If you're not familiar with this approach, the term "localhost" and the IP address 127.0.0.1 are synonymous. 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) my review here
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 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 = 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
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. 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 What can I do to fix this? Just ping localhost or this IP address from the command line, and you'll see that they are the same.
© Copyright 2017 ngogeeks.com. All rights reserved.