Wednesday, 29 June 2011

Create a MySQL User Account via the Terminal

First, Login to MySQL as an administrator account with:

mysql -u root -p

You will be prompted for your root password before being granted access to the MySQL

Now to check available user accounts on the system. type this command:

SELECT USER,host FROM mysql.USER;

If the user account that you wish to create doesn’t appear in that list
To create a new user account type this command:

CREATE USER 'new-username'@'localhost' IDENTIFIED BY 'password-for-new-account';

this user isn’t linked to any databases yet, but this is simple to rectify with a:

GRANT ALL ON mydatabase.* TO useraccount@localhost

that will grant all rights for the user account to everything held in the mydatabase database.

No comments:

Post a Comment