Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm trying to install a web app on my Ubuntu 12.04 server. The app is based on PHP and MySQL and I've got LAMP already working OK on my server - infact I've already got other apps working on PHP & MySQL already installed and working OK.

The problem I'm facing is, that when I try to run this app I get the error

Error: A Database connection using "Mysql" was missing or unable to connect. The database server returned this error: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '5.175.145.251' (111)

I have double and triple checked the username and password that I've put into the database.php and have confirmed that it's the same login credentials as what I use for phpMyAdmin and I'm even referring to the correct database (which as can be seen in phpMyAdmin, has been setup correctly.

For the install, I have followed the instructions at http://sourceforge.net/p/coopos/wiki/Install/ The only place I have differed is, "Step III. Configure the Virtual Host" - reason being, I cannot move from "/var/www" to "/home/username/public_html" as I already have other apps running under "/var/www"

My installation of the app (with all the error messages) can be seen at

http://5.175.145.251/pos

Would really appreciate some help on this, pls.

share|improve this question
add comment

3 Answers 3

It is a permissions error, it means you must check

  • Your database could be accesed from other hosts than localhost. if your localhost is 5.175.145.251, then use localhost, cause 5.175.145.251 is no localhost, then your database must have permission from 5.175.145.251 access
  • You database user, has permission from the host that you refer, it means, youruser@5.175.145.251
  • The port is open through a firewall or other
  • Finally, you could do a ping to your database host

Check that and then send a comment

share|improve this answer
    
You mean file permissions? 'cos if I change 'host' in database.php to either 'localhost' or '127.0.0.1' then I just get a 404 Page Not Found; but if I use the server's domain or IP# (5.175.145.251) then one see's what is currently available by going to 5.175.145.251/pos –  user93078 Jun 11 '13 at 14:27
    
I thought we are getting confused, I mean, one host is use app host, where your app is hosted, and one host is the database host, you must check on your database, wich user you you have and this user is accessed from... if you have a phpmyadmin or some kind of front end, check your database users, first at all you must check that, then you must compare with you php app –  Carlos Jun 11 '13 at 14:36
    
Error (111) is not a permissions error. –  Michael - sqlbot Jun 11 '13 at 15:03
    
it is a kind of access denied error dev.mysql.com/doc/refman/5.0/es/access-denied.html as the manual says, your could try to do a shell> netstat -ln | grep mysql for been sure that your server is running –  Carlos Jun 11 '13 at 15:15
add comment
sqlbot@dev:~$ /usr/local/mysql/bin/perror 111
OS error code 111:  Connection refused

Error code 111 (in parentheses, at the end) means "Connection refused." It is not a permissions error. It does not mean authentication failed. It means you are either trying to connect to the MySQL server using the wrong IP address or port, or the destination MySQL Server at the specified IP address and port isn't actually isn't running.

Even though the message says this...

The database server returned this error [...]

...the message is deceptive. What's actually happening is the database connector on the PHP side returned that error.

If this were a permissions error, you would see something like this:

SQLSTATE[28000] [1045]: Access denied for user 'foo'@'localhost' (using password: YES)
share|improve this answer
add comment

Although it does not seem like a permissions error per se, confirm bullet points 1 and 3 from Carlos's response: port is open on server and accessible, and/or change your connection URL to 127.0.0.1 if MySQL is treating your PHP app's request as TCP/IP from the outside.

Failing that, I would triple check the port and URL in the app's connection setup, if the last sentence of your first paragraph states that other PHP apps are working fine over this same database.

share|improve this answer
add comment

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.