Page 1 of 1

New MySQL user

PostPosted: 15. November 2007 22:05
by Kagaherk
Hi!

I've recently begun trying out XAMPP and I really like it so far. :) I'm having a problem however with creating a new MySQL user... I don't really like running PHP scripts with root MySQL access.

I've ran XAMPP security, and logging in to mysql command line using root and the root password works just fine. I used:

Code: Select all
/opt/lampp/bin/mysql -u root -p
...

CREATE DATABASE newdatabase;

GRANT ALL PRIVILEGES ON newdatabase.* TO 'newacc'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;


The last query returns 'Query OK, 0 rows affected', however, and logging in using this new user returns an error. I've also tried adding the user using PHPMyAdmin but with the exact same result.

Does anyone have an idea on how to do this correctly? :)

Thanks in advance,

PostPosted: 15. November 2007 23:52
by Wiedmann
however, and logging in using this new

You mean with:
Code: Select all
/opt/lampp/bin/mysql -u newacc -ppassword

?

returns an error

Which?

PostPosted: 16. November 2007 00:04
by Kagaherk
The error returned is:

Code: Select all
ERROR 1045 (28000): Access denied for user 'newacc'@'localhost' (using password: YES)

PostPosted: 16. November 2007 00:27
by Wiedmann
You have any anonymous user defined in MySQL?

PostPosted: 16. November 2007 01:04
by Kagaherk
Mmmm. As I haven't changed anything else in MySQL, I assume so. I have deleted the anonymous user(s) and... miraculously: my new account works! :D

It seems I missed this section of the MySQL manual.

Code: Select all
Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'@'%' account and thus comes earlier in the user table sort order.


Thank you very much for the fast responses :)