I have changed my MySQL datadir and socket location in my /etc/my.cnf
as follows:
[mysqld]
#--default datadir
#datadir=/var/lib/mysql
#--new datadir
datadir=/data/lib/mysql
#--default socket
#socket=/var/lib/mysql/mysql.sock
#--new socket
socket=/data/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# slow log
log-slow-queries=/var/log/mysqld-slow.log
long-query-time=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
#--default socket
#socket=/var/lib/mysql/mysql.sock
#--new socket
socket=/data/lib/mysql/mysql.sock
After writing my my.cnf as above, I restarted my mysqld with /etc/init.d/mysqld restart
.
I am able to connect to my MySQL via my terminal using mysql -uroot -ppassword
, and my data coorectly exists, so there is no problem there.
But when I try to connect to MySQL in a simple index.php as follows:
<?
$link = mysql_connect('localhost', 'root', 'password', TRUE);
echo $link;
?>
I get the error:
Warning: mysql_connect(): Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in /var/ww/html/index.php on line 3
I can't figure out why my PHP is trying to look for /var/lib/mysql/mysql.sock
, when I have obviously changed it to /data/lib/mysql/mysql.sock
.
I am running a normal Apache v2.2.22 loading a normal php5_module
.
I restarted my apache with both restart
and graceful
.
Does anyone know what's going on?