How to Create MySQL database & tables in Linux
Step 1: Login MySQL Database
Login to MySQL database using following command:
# mysql -u root -p Enter password: Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
Step 2: Create Database
To create database named “testdb”, execute the command:
mysql> CREATE DATABASE testdb;
Step 3: Select Database
Select and use the database:
mysql> USE testdb;
Step 4: Create Table
Next, create a table called user with name, email and id as fields:
mysql> CREATE TABLE user (id INT, name VARCHAR(30), email VARCHAR(30));
Step 5: Verify Table
In order to show the tables that are created, use the show command:
mysql> SHOW TABLES;