Tuesday, December 15, 2009

MySQL - Create database

The command is simple just write mysqladmin in a CLI followed by the database name you want to create


# mysqladmin -u root -p create building
# mysql


 Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.82-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW databases;
+----------+
| Database |
+----------+
| mysql    |
| building|
| test     |
+----------+
2 rows in set (0.00 sec)
mysql>


You can also type the query in mysql> prompt like this

mysql> CREATE database building;
Query OK, 1 row affected (0.00 sec)

To show available databases in mysql use the command show databases on mysql> prompt.
Now use the database by typing USE building and then type SHOW tables to see what tables are available in the database

mysql> USE building;
Database changed

mysql> SHOW tables;
Empty set (0.00 sec)

No comments:

Post a Comment