I opened every links google results had thrown to me in regards to this MySQL error. I have been spending hours to get this to work..
I have a web server
(apache in centos installed in host B, and want to connect to a MySQL server in host A) both hosts are in the same subnet.
I can access remote mysql using CLI
mysql -u root -h <ip> -p
but cannot connect to mysql using PHP function
I have already disabled
and included below syntax in /etc/my.cnf
[client] port =3306 socket = /var/lib/mysql/mysql.sock
Some solutions found in the web tells me to type in the
setbool associated with selinux, but the thing is, SELINUX is already disabled.
the odd thing is, I can connect thru CLI, but not in php function
also, I have
php-mysql in both hosts
Here is my main.php
<?php mysql_connect('192.168.8.136','root','admin') or die (mysql_error()); echo "Connected to MySQL server"; mysql_select_db("web") or die (mysql_error()); echo "Connected to Database"; ?>
here is my /etc/my.cnf
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld/log id-file=/var/run/mysqld/mysqld.pid
SELinux status: disabled
tcp 0 0 0.0.0.0:3306 0.0.0.0:* Listen
error received at client where apache is hosted:
[error] [client 127.0.0.1] PHP warning: mysql_connect(); cant connect to mysql server (13) in /var/www/html/main.php on line 2