Multiple MySQL Databases and mysql_select_db problem
Moderator: General Moderators
Multiple MySQL Databases and mysql_select_db problem
I've been working on one project for about six months now and recently decided to start on another when I ran into an aweful confusion: I don't remember setting up the first database and have no recollection of what I did to get the login and password set... I initially thought I would be able to use the same login and password for a second database but I can't get it to work from PHP (I can in the command dialog). What am I forgetting? Both databases are there and both have data in them, however I can only connect to the first. I'm pretty sure I didn't set any grants/permissions to any specific user since I'm relatively new to this. The error I get is the one I coded (echo...) when the mysql_select_db function does not return true. A friend of mine suggested that this might be caused by a connection already existing to the first project, however I'm not so sure that would be true since I have tested it upon reboot. I am using persistent connections (mysql_pconnect) though. The funny thing is that my first project still works fine. HELP!
Your going to want to run the following command to see what the permissions are for the particular user your currently using.
Your looking for what appears after the "ON" keyword. A start "*.*" means this user can run all databases and all tables. A "my_bd.*" mean that user can access "my_db" database and all the tables in it. Make sure the user has a *.* or includes both databases your using. This will tell you once and for all it the problem is with the permissions set on the user.
Hope this helps,
Code: Select all
mysql> SHOW GRANTS FOR your_user@your_host;Hope this helps,
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
I'd do what EricS said but something that can make debugging easier is to use mysql_error():
Mac
Code: Select all
mysql_select_db('db_name') or die(mysql_error());- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK