How to generate a new MySQL database

Please follow the instructions below to create a new database for MySQL.


First we need to login to MySQL server
Windows Servers

C:\pathto\to\bin\mysql\mysql5.1.36\bin>mysql -u root –p

Unix Servers

mysql -u root -p

If you did not issue a “root” user password earlier, then just press “Enter” to bypass, otherwise enter the password you had set.

After a successful login , the MySQL monitor starts and displays the following greeting:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.36-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Please choose the database name you want to use and run the following command
mysql> CREATE DATABASE newdatabase;
Query OK, 1 row affected (0.04 sec)

You need to flus priviliges
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.17 sec)

In order to check if your database is successfully created please use the following command.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| newdatabase |
| mysql |
| test |
+--------------------+
4 rows in set (0.01 sec)

Random Posts

  1. No comments yet.

  1. No trackbacks yet.