Search our database

How to create new database and new database user using terminal

Create New Database

1. Login to the mysql client.

mysql -u root -p

2. Use the command below.

mysql> CREATE DATABASE ''databasename'';

3. Commands below can be used to grant privileges for a database user for database. If database user is not created, please scroll down for the tutorial.

mysql> GRANT ALL PRIVILEGES ON ''databasename''.* TO "''username''"@"''hostname''" IDENTIFIED BY "''password''";
mysql> FLUSH PRIVILEGES;

Create New Database User

1. Login to the mysql client.

mysql -u root -p

2. Use the command below.

create user 'new-username'@'localhost' identified by 'password-for-new-account';

Extra: For DirectAdmin based Linux server, you may login to mysql using the DirectAdmin mysql root account. You can loate it in:

/usr/local/DirectAdmin/conf/mysql.conf