Skip navigation links

MySQL Forums :: PHP :: creating database users


Advanced Search

creating database users
Posted by: peter le roux ()
Date: December 18, 2012 02:15AM

Hello.

i am busy with a database thing. to get this used on a larger server i want to create a username for this database only.
so i create one at install (php event on first run) which executes this on the database:

$sql = "grant ALL on ".DATABASE_NAME.".* to '".$usn."' identified by '".$pwd."' with grant option;";

the 'with grant option' i added to test if it helps (it doesn't)
so:
- the user is created on the database no problem.
- when i try to use it in the next step, it fails like this:

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'BOREHOLES'@'localhost' (using password: YES) in D:\bhdb\www\php\_dbmysql.php on line 32
could not connect: 1045

when i check the database users with phpmyadmin, the user does exist with rights as i specified.

yet i can't use it...

what am i missing?

thanks.
peter

ps:
i also tried creating the username with no password.
i also tried giving the username global access.
i tried at this point to use root, and it worked as it would.



Edited 1 time(s). Last edit at 12/18/2012 02:26AM by peter le roux.

Options: ReplyQuote


Subject Written By Posted
creating database users peter le roux 12/18/2012 02:15AM
Re: creating database users peter le roux 12/18/2012 02:22AM
Re: creating database users Peter Brawley 12/18/2012 11:31AM
Re: creating database users peter le roux 12/19/2012 01:01AM
Re: creating database users Peter Brawley 12/19/2012 01:07AM
Re: creating database users peter le roux 12/19/2012 02:19AM
Re: creating database users Barry Galbraith 12/19/2012 05:43AM
Re: creating database users peter le roux 12/19/2012 07:42AM
Re: creating database users Barry Galbraith 12/19/2012 03:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.