Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running on RHEL6. I have installed php and php-mysql.

<?php phpinfo(); ?> is working perfectly.

But I can't connect to MySQL is there a way to confirm that php-mysql is not working on my server

[EDIT]

I'm trying to connect to a remote database from a webpage when I open up my webpage it displays Can't connect to MySQL server on 'ipaddress' (110)

Remote database is working and I can successfully telnet to that ip from my ip and port 3306

share|improve this question
    
What errors are you getting? What configuration have you done? Did you confirm that your mysql daemon is up and running? Can you connect and use the database with other tools? –  Mat May 21 at 6:51
    
I have only installed php-mysql because my database is on a remote server. I haven't done any configuration changes –  ivcode May 21 at 7:01
    
as for the errors, my page displays Can't connect to MySQL server on 'ipaddress' (110) –  ivcode May 21 at 7:02
    
Please edit your question to add those details. Also include whether you can connect successfully to that database with other tools from that machine. –  Mat May 21 at 7:03
    
Do you have SE Linux in enforcing mode? Check the logs to see if your policy is blocking db connections. Also, is this running via Apache or fast cgi? –  cpugeniusmv May 21 at 7:51

2 Answers 2

you can use service command:

service mysqld status
share|improve this answer
    
It's not working as I have only php-mysql installed –  ivcode May 21 at 7:03

Since you can establish a TCP connection (over telnet), it sounds like the problem that there is not a grant on the remote database server for the user your are using in your code.

On the remote database side, you will want to run a query like the following. This should add the appropriate grants for the account you are using from the IP address you are connecting from.

GRANT ALL PRIVILEGES ON `database`.* TO 'username'@'cli.ent.ipa.ddr' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
share|improve this answer
    
i'm currently using root credentials –  ivcode May 21 at 7:29
    
It is possible that the root user only has a grant for localhost (i.e. unix socket), as it is generally not a good idea to use the root credentials for remote connectivity. If you run the following query, you can double check if there is a grant for the root user that allows remote connectivity: SELECT user, host FROM mysql.user; –  Izkuru May 21 at 7:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.