ID: 9601
User Update by: [EMAIL PROTECTED]
Status: Closed
Bug Type: MySQL related
Description: MySQL connects to wrong database

The grant tables are fine. Perhaps we misunderstood ourselves.

If I use "mysql" to connect to the live database using a user name and password that 
is in the grant tables, it works fine.

If I use "mysql" to connect to the test database using a user name and password that 
DOES NOT HAVE PRIVILEGES to this database, authentication fails, as it should.

If I use PHP to connect to the live database using a user name and password that is in 
the grant tables, it works fine.

If I use PHP to connect to the test database using the SAME user name and password 
that works for the live database, it connects to the LIVE database instead of the test 
database.

We found this by accident when setting up a test web site that duplicates a live site. 
When I changed the database name in the connection object, it didn't fail, it just 
connected to the live database.

Previous Comments:
---------------------------------------------------------------------------

[2001-03-07 10:59:54] [EMAIL PROTECTED]
USER NOTES FROM EMAIL:

I just used --with-mysql

AND

ERROR 1045: Access denied for user: 'ceresdb@localhost' (Using password:
YES)

When executing the mysql command from a bash shell.

Greg

---------------------------------------------------------------------------

[2001-03-07 10:59:01] [EMAIL PROTECTED]
Please use the bug system when replying.  Thanx.

Well it looks like you don't have the Grant Tables setup properly OR you didn't flush 
them after changing them.

Do a `mysqladmin reload` and try again, if it still doesn't connect then you need to 
fix your grant tables.

See http://www.mysql.com/documentation/index.html for information on how to do this.

I haven't seen it cause any problems, but just to be safe you should recompile PHP 
using --with-mysql=/path/to/mysql so PHP is aware of what version you are actually 
using.

If for some reason your grant tables are not the problem simply reopen this report.

-Chris


---------------------------------------------------------------------------

[2001-03-07 10:45:31] [EMAIL PROTECTED]
Couple stupid questions.

1) When you compiled PHP, did you just use --with-mysql instead of 
--with-mysql=/path/to/mysql?

2) Does the mysql command line tool connect? i.e. mysql -u ceres -pxxxx ceres_test

-Chris

---------------------------------------------------------------------------

[2001-03-07 09:34:33] [EMAIL PROTECTED]
MySQL: 3.22.32-beta
Apache: 1.3.14

MySQL is connecting to the wrong database:

I have two databases:

ceres
ceres_test

The ceres database is the live database and the user "ceres" is granted permissions on 
it.

The ceres_test database is a database that is identical, but I use for testing 
purposes.

The mysql user "ceresdb" has permissions to access the "ceres" database ONLY.

However, if I execute:

mysql_pconnect("localhost","ceresdb", "password");
mysql_select_db("ceres_test");

It actually connects to the "ceres" database instead. I should have recieved and error 
that it was unable to connect.

We have verified this several ways.

Also, if I change the username/password to the root user or a user that has 
permissions on ALL databases, it works fine.


---------------------------------------------------------------------------


Full Bug description available at: http://bugs.php.net/?id=9601


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to