0

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.

0

This does not seem to be Ubuntu related per se.
For figuring out the permissions required for PHP files you can go through https://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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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