Koozali.org: home of the SME Server

Mysql connection problem

grahowler

Mysql connection problem
« on: July 11, 2003, 08:27:43 AM »
Hi

I have some confusion regarding mysql users and connection. I recently set up a new e-smith installation and in doing this I installed phpMyAdmin for the root user with the 76 character root password, no probs here. Then I created a database I needed and imported all the necessary data via phpMyAdmin, no probs here either.

Then I created a user for the database by entering the following query in phpMyAdmin:

GRANT
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP
ON myDB.*
TO myUser@localhost
IDENTIFIED BY 'myUserPW';

From this a new entry is created in the MYSQL database USER table, as you would expect. But the following script returns 'NO'.

PHP Code:

$dbCon = mysql_connect('localhost', 'myUser', 'myUserPW');
$dbCon = mysql_select_db('myDB', $dbCon);

if (mysql_query('SELECT 1 AS Query1', $dbCon)) echo 'YES';
else echo 'NO';

When viewing the contents of the MYSQL USER table the user 'myUser' has been created and is in the table with all the privileges set to 'N'. When running the query 'SHOW GRANTS FOR myUser@localhost' the following two rows are returned:

GRANT USAGE ON *.* TO 'myUser'@'localhost' IDENTIFIED BY PASSWORD '123abc456def(etc..)'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON myDB.* TO 'myUser'@'localhost'

I tried running the query FLUSH PRIVILEGES and I also tried re-starting mysql but neither of those things helped. Then I tried changing the username and password in mysql_connect to the root username and password and the script won't run either.

I've been using MYSQL for a while now and I have never encountered problems like this so I can only assume it has to be an e-smith problem. I am a bit confused so all help is greatly appreciated.

Thx in advance!

Stelli

Re: Mysql connection problem
« Reply #1 on: September 25, 2003, 06:54:40 PM »