Create mariadb user, password from cli

While developing a CMS we don't have phpmyadmin, plesk or cpanel rather a simple cli. So to create a quick DB with a user who has all privileges to the DB and a password to the user just give these commands. I think this method works for mysql too.

$ mysql -u adminusername -p
Enter password:
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON databasename.* TO "username"@"hostname" IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> EXIT

Bhuvan Krishna

Read more posts by this author.