MySQL not working on localhost

jwnmedia

Verified User
Joined
Nov 20, 2013
Messages
20
I have been stuck with this problem since installing hive on my server, mySQL.sock had been moved to the temp directory so installatron and directadmin could not access it. I have since modified my.cnf in root and told it to put mySQL.sock back in var/lib/mysql/mysql.sock and made sure the directory was readable by everyone. Now directadmin can access the databases again but all scripts with localhost will not work. Instead you need to use 127.0.0.1. I checked the system and ensured pinging localhost came back to 127.0.0.1 and that host localhost also comes back to 127.0.0.1. I am really getting aggravated with this since its a production server and I am getting emails from clients whos scripts are not working. Can someone help with this or fix it for me. I am willing to pay.
 
Check you have a localhost entry in /etc/hosts. The file you should be editing is /etc/my.cnf too
 
I did. 127.0.0.1 localhost localhost.localdomain is in etc/host and /etc/my.cnf is what I added socket=/var/lib/mysql/mysql.sock to
 
Check your dns servers in /etc/resolv.conf and see if they are resolving localhost fine.

Code:
dig @nameserver-ip +short localhost
 
Try this in a php file and see if it resolves it fine.

Code:
<?php print(gethostbyname("localhost")."\n"); ?>
 
Also from ssh I get this

[root@69 ~]# mysql -u da_admin -h localhost -D test
ERROR 1045 (28000): Access denied for user 'da_admin'@'localhost' (using password: NO)

So it seems to answer in ssh as localhost as well. Going to try the other script you sent as well.
 
Just to let you know, I have tried to create a database in DA and not da is looking for mysql.sock in /tmp/mysql.sock so it wont let me.
 
Also if I let mySQL create the sock file in /tmp/mysql.sock all the scripts work correctly with localhost, however installatron can not install the scripts since its looking in /var/lib/mysql/mysql.sock but now that I put it back where it was in /var/lib/mysql/mysql.sock nothing works anymore and directadmin is now looking in /tmp/mysql.sock so I am just getting a bit frustrated.
 
When I ls I get it in ssh however

[root@69 ~]# ls -la /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Nov 20 01:35 /var/lib/mysql/mysql.sock
 
Also there was a line socket=/tmp/mysql.sock in /usr/local/directadmin/conf/my.cnf I removed it and directadmin works for managing mySQL again.
 
Anyway to go back to normal php settings? I have custombuild and I ran ./build all d last night hoping it would repair everything to no avail
 
You might have an old php install or something. I would reinstall php via custombuild.

Code:
cd /usr/local/directadmin/custombuild
./build update
./build clean
./build php d

You may also need to do:

Code:
./build rewrite_confs
 
Did build php and configs still no go but now php shows in /usr/local/lib/php.ini
 
Back
Top