Login to MySQL via command line


Login to MySQL

First we’ll login to the MySQL server from the command line with the following command:

mysql -u root -p

In this case, I’ve specified the user root with the -u flag, and then used the -p flag so MySQL prompts for a password. Enter your current password to complete the login.

If you need to change your root (or any other) password in the database, then follow this tutorial on changing a password for MySQL via the command line.

You should now be at a MySQL prompt that looks very similar to this:


Create MySQL User

We’ll create a user with the name testuser , and the password test123test!.

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';

That’s it, congratulations! In just one command you’ve created your first MySQL user. However, this user won’t be able to do anything with MySQL until they are granted additional privileges. In fact, they won’t even be able to login without additional permissions.

To give the new user proper permissions, work through our tutorial on granting permissions to MySQL user’s via the command line.

View a List of MySQL Users

Viewing a full list of MySQL users, including the host they’re associated with, can be done with the following select statement:

SELECT User,Host FROM mysql.user;

2015-10-02 09:34:25gstlouis

reference: http://www.liquidweb.com/kb/create-a-mysql-user-on-linux-via-command-line/

2015-10-02 09:34:40

some inputs for franting


  •  grant all on powerbui_powerbuild to 'powerbui_admin';
  • grant all on powerbui_powerbuild.* to 'powerbui_admin';

2015-10-02 10:26:05