Re: Database visible via mysql CLI but not MOD_PHP with
| From: | Elliot Mackenzie | Date: | Wed, 16 Feb 2005 13:13:45 +0000 |
| Subject: | Re: Database visible via mysql CLI but not MOD_PHP with | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-38596@lists.php.net to get a copy of this message | ||
I have an update for this.
I used mysql_connect to connect to the database and then ran the query "select current_user()". I discovered that despite using mysql_connect specifying a username and password, it still insisted on connecting as "@localhost", but with no user.
The @localhost user does not have the permissions it needs to show databases other than "test", and this explains 100% why I am seeing the results I am seeing. I can login to the command-line client and see exactly what PHP is seeing now (which is a relief).
The question is now: why would I be connecting as "@localhost" instead of "user@localhost" when I specify both a username and password along with mysql_connect?
There are no mysql-related defaults set in php.ini other than a path to the socket.
Kind regards,
Elliot.
Martin Norland wrote:
Elliot Mackenzie wrote:I have encountered a "hidden database" issue with mod_php, apache2 and mySQL that I have thus far been unable to resolve. I am able to connect to the mysql socket using mysql_connect, but then find that mysql_list_dbs only returns the "test" database. This *sounded* like an issue with the SHOW DATABASES privilege until I found I was able to log in to the same MySQL server *as the same user* with the provided command-line client (mysql) and SHOW DATABASES would display all the other databases on this system. Furthermore, I tried connecting as root, and again found only the "test"
database was visible to PHP. If I dropped the test database, no databases were visible to PHP (regardless of how many databases were visible using SHOW DATABASES). If I created "test", "tester", "testing", "hello" etc, then the "test" database would reappear to PHP, but no other databases were visible. I also tried to connect PHP to MySQL as a super-user, and encountered the exact same issue.Steps to confirm question: 1) Connect using php, drop 'test' database. 2) Confirm php no longer sees 'test' database. 3) Connect using mysql client, confirm test database is missing. 4) -----\4a) if so, check mysql database to confirm permissions for rootinclude '%' databases and not just 'test'.4b) if not, change php code to connect to correct mysql server.Apologies that this may not be very useful, but your problem is extremely odd - if it's *not* a permissions / database error. Cheers,