First you can login as root on your mysql server using:
If a password is required,
Code:
$ mysql -u root -p
Enter password:
You should now be at a MySQL prompt that looks very similar to this:
We can now create a database by run command:
Code:
CREATE DATABASE tutorial_database;
Code:
Query OK, 1 row affected (0.00 sec)
The database name we have chosen already exists, run command:
Code:
CREATE DATABASE IF NOT EXISTS tutorial_database;
Code:
Query OK, 1 row affected, 1 warning (0.01 sec)
If we leave the "IF NOT EXISTS" option off, and the database already exists, we will receive the following error:
Code:
ERROR 1007 (HY000): Can't create database 'tutorial_database'; database exists
To view a list of the current databases, use run command:
Bookmarks