Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed apache2, php5, mysql-server, php5-mysql, phpmyadmin in that order on Ubuntu 12.04 with the Software Center. Apache and PHP works fine, no problems. Also, if I try to work with MySQL via phpmyadmin, everything works as expected. Problems start, when I want to use MySQL via PHP. For this I tried the following script:

$connection = mysql_connect($host, $user, $pw) OR die(mysql_errno()." ".mysql_error());
mysql_select_db($db, $connection) OR die(mysql_errno()." ".mysql_error());

This returns "1046 No database selected". I'm sure that the database exists, I even tried it with the standard "test"-database and root as the user. What made me really curious, is that when I use a non-existent user ("asdf"), the same message appears and no failure from the mysql_connect-function.

This leads me to the suspicion, that I struggle with user rights in the Linux system, because it works with phpmyadmin, which is not installed via a webinstaller but via the Software Center. I can only guess that hence, phpmyadmin has other rights to access MySQl than PHP, but I don't know, how to approach the problem. After trying and googleing for hours, I feel a bit lost now. Please help me.

share|improve this question

1 Answer 1

This does not seem to be Ubuntu related per se.
For figuring out the permissions required for PHP files you can go through http://stackoverflow.com/questions/2096255/what-permissions-for-php-scripts-directories

phpMyAdmin will most probably be located in /usr/share/phpmyadmin you can look up the settings it is using.
http://rudyegenias.wordpress.com/2006/09/15/enabling-phpmyadmin-once-you-change-permission-or-privileges-on-mysql-database/ might be useful which suggests looking at config.inc.php.

share|improve this answer

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.