How to create mysql db from bash command line

1st connect to mysql deamon

[root@localhost html]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.

now to create a database named lee use

mysql> create database lee;
Query OK, 1 row affected (0.01 sec)

next grant a user the rights to access this database

mysql> grant all privileges on lee.* TO 'user'@'localhost' IDENTIFIED BY 'password';

where password is your own password

next
mysql> FLUSH PRIVILEGES ;
Query OK, 0 rows affected (0.00 sec)

the above commands for creation of mysql database using command line were tested in CentOS running mysql 5.0.45

Leave a Reply