[Resolved] can not connect to mysql

phattran911

Well-Known Member
#1
I just installed litespeed and my site returns that it can not connect to mysql.

The server is CentOS 5 64 bit

Here is the info

PHP:
root@361399-live2 [~]# /usr/local/lsws/fcgi-bin/lsphp5 -i|grep default_socket
mysql.default_socket => no value => no value
default_socket_timeout => 60 => 60

PHP:
root@361399-live2 [~]# ps -ef|grep mysql
root      5697  7164  0 12:24 pts/1    00:00:00 grep mysql
root      8196     1  0 Jul25 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid
mysql     8220  8196 14 Jul25 ?        1-01:32:09 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --skip-external-locking

There is the php.ini file in the /usr/local/lsws/php, I edit to this code
PHP:
; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/lib/mysql/mysql.sock
but it still don't work

Can you please help?

Thanks
 
Last edited by a moderator:

phattran911

Well-Known Member
#3
It is there

PHP:
root@361399-live2 [~]# ls -l /var/lib/mysql
total 20716
drwxr-x--x 10 mysql mysql     4096 Jul 29 15:19 ./
drwxr-xr-x 30 root  root      4096 Jul 25 00:09 ../
-rw-rw----  1 mysql root    118175 Aug  1 10:27 361399-live2.boxlive.tv.err
-rw-rw----  1 mysql mysql        5 Jul 25 00:00 361399-live2.boxlive.tv.pid
drwx------  2 mysql mysql    20480 Jul 29 15:24 boxlive_home/
drwx------  2 mysql mysql     4096 Jul 25 00:08 cphulkd/
drwx------  2 mysql mysql     4096 Aug  1 00:09 eximstats/
drwx------  2 mysql mysql    16384 Jul 25 11:12 hopphim_home/
drwx------  2 mysql mysql     4096 Jul 24 23:47 horde/
-rw-rw----  1 mysql mysql 10485760 Jul 25 00:09 ibdata1
-rw-rw----  1 mysql mysql  5242880 Jul 25 00:09 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 Jul 24 23:46 ib_logfile1
drwx------  2 mysql mysql     4096 Jul 25 00:02 leechprotect/
drwx--x--x  2 mysql mysql     4096 Jul 24 23:46 mysql/
srwxrwxrwx  1 mysql mysql        0 Jul 25 00:00 mysql.sock=
drwx------  2 mysql mysql     4096 Jul 25 00:09 roundcube/
root@361399-live2 [~]#
 

NiteWave

Administrator
#4
it's "mysql.sock=", not "mysql.sock"
can you try php.ini
PHP:
; Default socket name for local MySQL connects.  If empty, uses the built-in 
; MySQL defaults. 
mysql.default_socket = "/var/lib/mysql/mysql.sock="
 

phattran911

Well-Known Member
#5
It is still not working

PHP:
; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/lib/mysql/mysql.sock=
I note that this php.ini is the /usr/local/lsws/php/php.ini



Is there anything to do with /usr/local/lib/php.ini? Do I need to modify anything in this php.ini?

Thanks
 

phattran911

Well-Known Member
#6
Now I am thinking I modified the wrong php.ini.

Which of those php.ini needs modification?

PHP:
root@361399-live2 [~]# locate php.ini
/etc/php.ini
/home/cpeasyapache/src/php-5.3.2/php.ini-development
/home/cpeasyapache/src/php-5.3.2/php.ini-production
/root/lsws-4.0.15/add-ons/cpanel/lsws_whm_plugin/php.ini
/root/lsws-4.0.15/add-ons/directadmin/php.ini
/root/lsws-4.0.15/admin/conf/php.ini
/root/lsws-4.0.15/admin/misc/php.ini
/root/lsws-4.0.15/php/php.ini
/scripts/php.ini
/usr/lib/php.ini
/usr/local/cpanel/3rdparty/etc/php.ini
/usr/local/cpanel/3rdparty/etc/php.ini.dist
/usr/local/cpanel/3rdparty/etc/php.ini.keep
/usr/local/cpanel/3rdparty/etc/horde/php.ini
/usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
/usr/local/cpanel/3rdparty/etc/phppgadmin/php.ini
/usr/local/cpanel/3rdparty/etc/roundcube/php.ini
/usr/local/cpanel/whostmgr/docroot/cgi/lsws/php.ini
/usr/local/lib/php.ini
/usr/local/lib/php.ini,v
/usr/local/lsws/add-ons/cpanel/lsws_whm_plugin/php.ini
/usr/local/lsws/add-ons/directadmin/php.ini
/usr/local/lsws/admin/conf/php.ini
/usr/local/lsws/admin/misc/php.ini
/usr/local/lsws/php/php.ini
I was trying to edit the /usr/local/lsws/php/php.ini
 

phattran911

Well-Known Member
#8
It shows /usr/local/lib/php.ini is loaded.

I already changed the default_socket to the suggested in this file, restart both Apache and Litespeed, but it still won't work. It took me already some days to test but still can't figure it out.

Is there anything else to check? Thanks
 

NiteWave

Administrator
#11
add
--socket=/var/lib/mysql/mysql.sock
to start mysqld
so that in "ps -ef|grep mysql" it looks like
Code:
/usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
 

phattran911

Well-Known Member
#12
can you please give me the full command to start mysqld with --socket=/var/lib/mysql/mysql.sock

Is this command correct?

PHP:
service mysql start --socket=/var/lib/mysql/mysql.sock
I am sorry I really don't know much about this

Thanks
 

phattran911

Well-Known Member
#13
I stopped and started mysql again with the above command. Now I got

PHP:
root@361399-live2 [~]# ps -ef|grep mysql
root     27420     1  0 15:18 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --socket=/var/lib/mysql/mysql.sock
mysql    27447 27420 10 15:18 pts/1    00:00:12 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
root     27883  7164  0 15:20 pts/1    00:00:00 grep mysql

However the following command still give NO VALUE
PHP:
root@361399-live2 [~]# /usr/local/lsws/fcgi-bin/lsphp5 -i|grep default_socket
mysql.default_socket => no value => no value
default_socket_timeout => 60 => 60
 

phattran911

Well-Known Member
#14
can anyone help me please? Why this command show no value

/usr/local/lsws/fcgi-bin/lsphp5 -i|grep default_socket

no value for mysql.default_socket

Thanks
 

NiteWave

Administrator
#15
have you changed back in php.ini to
mysql.default_socket = /var/lib/mysql/mysql.sock
?

anyway, settings in various places need to be consistent:
1.ps -ef|grep mysql
"--socket=/var/lib/mysql/mysql.sock should be there
per your previous post, now it's there

2. ls -l /var/lib/mysql/
check if mysql.sock exists

3.check /usr/local/lib/php.ini if
mysql.default_socket = /var/lib/mysql/mysql.sock

4.check phpinfo() if
mysql.default_socket = /var/lib/mysql/mysql.sock

5.DB Host should use "localhost", not 127.0.0.1
 

phattran911

Well-Known Member
#16
I have checked everything carefully

1. Correct:
PHP:
root@361399-live2 [~]# ps -ef|grep mysql
root      3111  7164  0 21:00 pts/1    00:00:00 grep mysql
root     27420     1  0 15:18 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --socket=/var/lib/mysql/mysql.sock
mysql    27447 27420 11 15:18 pts/1    00:37:46 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/361399-live2.boxlive.tv.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
2. "mysql.sock=" is still there. When I used SFTP to browse the server, it is only "mysql.sock" so I am not sure what the "=" is there.

PHP:
root@361399-live2 [~]# ls -l /var/lib/mysql/
total 20716
drwxr-x--x 10 mysql mysql     4096 Aug  1 15:18 ./
drwxr-xr-x 30 root  root      4096 Jul 25 00:09 ../
-rw-rw----  1 mysql root    118773 Aug  1 15:18 361399-live2.boxlive.tv.err
-rw-rw----  1 mysql mysql        6 Aug  1 15:18 361399-live2.boxlive.tv.pid
drwx------  2 mysql mysql    20480 Jul 29 15:24 boxlive_home/
drwx------  2 mysql mysql     4096 Jul 25 00:08 cphulkd/
drwx------  2 mysql mysql     4096 Aug  1 00:09 eximstats/
drwx------  2 mysql mysql    16384 Jul 25 11:12 hopphim_home/
drwx------  2 mysql mysql     4096 Jul 24 23:47 horde/
-rw-rw----  1 mysql mysql 10485760 Aug  1 16:30 ibdata1
-rw-rw----  1 mysql mysql  5242880 Aug  1 16:30 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 Jul 24 23:46 ib_logfile1
drwx------  2 mysql mysql     4096 Jul 25 00:02 leechprotect/
drwx--x--x  2 mysql mysql     4096 Jul 24 23:46 mysql/
srwxrwxrwx  1 mysql mysql        0 Aug  1 15:18 mysql.sock=
drwx------  2 mysql mysql     4096 Jul 25 00:09 roundcube/
3. It is correct
4. It is correct
5. Do you mean in the configuration.php file of the site? If so, I am using joomla and its configuration.php databae host is localhost

I really need to test litespeed and I am ready to buy license. I just need to fix this issue.

What about this command?
PHP:
root@361399-live2 [~]# /usr/local/lsws/fcgi-bin/lsphp5 -i|grep default_socket
mysql.default_socket => no value => no value
default_socket_timeout => 60 => 60
Why is it showing no value for default_socket.

I think this is the problem
 

phattran911

Well-Known Member
#18
The current phpinfo() show

Loaded Configuration File
/usr/local/lib/php.ini

This is the loaded php.ini file

This is also the file that I edited.

What directory do I need to put the php.ini in?

Thanks
 

phattran911

Well-Known Member
#20
I think I got the problem fixed.

For the info, I went to the WHM control panel, then run build match php. This will build the php (actually copied from apache) for litespeed.

Now it works

Thanks
 
Top