[nycphp-talk] mysql connection
William Klein
willie at pdfsystems.com
Fri Nov 12 16:47:02 EST 2010
I figured it out it was SELINUX
Now I need to figure out how to get SELINUX not to interfere with the
apache-mysql connection.
If anyone knows I wouldn't mind but it's really time to start my research on
that, most likely on a different list.
Thanks
From: William Klein [mailto:willie at pdfsystems.com]
Sent: Friday, November 12, 2010 4:33 PM
To: 'NYPHP Talk'
Subject: Re: [nycphp-talk] mysql connection
Yeah I understand that. I can connect from the apache server with
mysql -u root -h 192.168.199.31 -p
but the php connect fails with
Warning: mysql_connect() [function.mysql-connect
<http://192.168.199.30/function.mysql-connect> ]: Can't connect to MySQL
server on '192.168.199.31' (13) in /var/www/html/order/test.php on line 2
Could not connect number2003 error Can't connect to MySQL server on
'192.168.199.31' (13)
Error 2003 is permission denied and so is 13 but I'm using the same user:
Test code:
<?phnk = mysql_connect('192.168.199.31:3306','root','xxxx');
if(!$link){
die("Could not connect number". mysql_errno()." error "
.mysql_error());
}
?>
Strange, which is why I was looking at the php complile.
The phpinfo() command does mention the mysql sock in /var/lib/mysql but no
mention of a tcp connection I thought perhaps there was a compile parameter
I'm missing.
From: Rob Marscher [mailto:rmarscher at beaffinitive.com]
Sent: Friday, November 12, 2010 4:08 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] mysql connection
On Nov 12, 2010, at 4:02 PM, willie klein wrote:
Setting up a new server and finally splitting my apache server and mysql
server into 2 virtual boxes.
For some reason I can't connect to the remote server with php but I can
connect with mysql command line.
I think it must be some way I compiled php, tried just using rpms also.
I'm not sure it's your php compilation. What about mysql permissions? Can
you connect via mysql command line running on your apache server to the
mysql server? Also want to make sure the port is open on the mysql server
(usually 3306) and that the mysql server doesn't have "skip-networking" in
it's my.cnf. The permissions for mysql users includes the hostname that
user is allowed to connect from. If you want to open up the permissions for
the user so they can connect from any server, you want to do something like
this:
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT USAGE ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `dbname` . * TO 'username'@'%';
FLUSH PRIVILEGES;
The % wildcard allows the user to connect from any host.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20101112/a0d0c26b/attachment.html>
More information about the talk
mailing list