Create Database and tables in MySQL

Create Database and tables in MySQL

Hi,

How to create database and tables in MySQL Database? Explain me step-by-step as I am beginner in MySQL.

Thanks

View Answers

June 26, 2016 at 12:28 AM

Hi,

First of all you have to connect to MySQL database through command line tool.

Connecting to MySQL Database:

mysql -uroot -p

Here in -uroot, root is the username of database. Replace this with your database user name for example if your username is 'abc' then the command will be:

mysql -uabc -p

Press enter on the command prompt/terminal and mysql command line tool will ask for the password. Enter the password and if password is correct mysql prompt will open.

deepak@deepakub16:~$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.12-0ubuntu1.1 (Ubuntu)

Copyright (c) 2000, 2016, 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>

Now to create database use following command:

mysql> CREATE DATABASE tutorial;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| tutorial           |
+--------------------+
5 rows in set (0.00 sec)

The show databases; command displays the names of the databases.

Now you have to connect to database, type following command:

mysql> connect tutorial;
Connection id:    6
Current database: tutorial

Here is the sql to create table:

mysql> CREATE TABLE email
    -> (
    -> first_name varchar(20),
    -> last_name varchar(20),
    -> email varchar(40),
    -> email_count Int
    -> )
    -> ;
Query OK, 0 rows affected (0.02 sec)

Following command displays the newly created table:

mysql> show tables;
+--------------------+
| Tables_in_tutorial |
+--------------------+
| email              |
+--------------------+
1 row in set (0.00 sec)

mysql>

Check more tutorials at Create a database.

Check 100s of tutorials of SQL at SQL Tutorials with MySQL Database.

Thanks









Related Tutorials/Questions & Answers:
Create Database and tables in MySQL
Create Database and tables in MySQL  Hi, How to create database and tables in MySQL Database? Explain me step-by-step as I am beginner in MySQL. Thanks   Hi, First of all you have to connect to MySQL database through
MySQL Create Database
MySQL Create Database        ... to create the database on MySQL Server. MySQL Database server is one of the very.... Here is the video tutorial of: "How to create MySQL Database?"ADS
Advertisements
Create xsd files from database tables
Create xsd files from database tables  Hi, I work on a Java JEE... database tables.... At the moment we write the xsd files representing a database table structure by hand
Video Tutorial: How to create a database in MySQL using Command prompt?
How to create a database in MySQL using Command prompt MySQL is an Operation... is the video tutorial of "How to create database in MySQL using command prompt... in MySQL using command prompt. To create a database we need to use
Mysql List Tables
Mysql List Tables     ... of tables in database name 'Table_in_girish'. The Syntax used to display the list of tables in database are given below: show tables :The showtables is used
Setting up MySQL Database and Tables
Setting up MySQL Database and Tables   ... Database and you know how to work with the MySQL database. To access the database... DATABASE `struts-hibernate` ; CREATE TABLE
How can we create a database using PHP and mysql?
How can we create a database using PHP and mysql?  How can we create a database using PHP and mysql
program to create nested tables
program to create nested tables  program to create nested tables
Retrieving Tables from a Database
Retrieving Tables from a Database   ... a table and create a table in the database. This section provides you a facility for retrieving tables from a specific database through an example. In relational
MYSQL Database
MYSQL Database  Can any one brief me about how to use MYSQL Database to store the create new database, create tables. Thanks.   Hi, the MySQL database server is most popular database server and if you want to know
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
How to create database in mysql using ANT build - Ant
How to create database in mysql using ANT build  Hello , can anybody tell me how to create a database in mysql using ant build.Please tell... in build.xml to create a database: Create Database roseindia For more
Different tables present in MySQL
; Hi friends, Total 5 types of tables we can create 1. MyISAM 2. Heap 3... When you fire the above create query MySQL will create a MyISAM table. Thanks...Different tables present in MySQL  What are the different tables
Setup MySQL Database
/mysql/mysql5/Installing-MySQL-on-Windows.shtml Creating Database : You can create...Setup MySQL Database          In this section we will create database and table
Mysql List Tables
Mysql List Tables      ... of tables in database name 'Table_in_girish'. The Syntax used to display the list of tables in database are given below: show tables: The showtables is used to show
Create a counter in mySQL 5 database through Java - SQL
Create a counter in mySQL 5 database through Java  Dear Editor... question regarding Java & mySQL 5 database.... ============================================================== This is an example of mySQL5 database as shown above. For example "Bee
MySQL Database Training
MySQL data with SQL. How to create a simple MySQL database Table... MySQL Database Training      ... Creating and Modifying Tables with MySQL
Welcome to the MySQL Tutorials
;    MySQL Create Database In This lesson you will read MySQL Create Database is a component... of tables.    MySQL Database
Create a Table in Mysql database through SQL Query in JSP
Create a Table in Mysql database through SQL Query in JSP...; This is detailed java code to connect a jsp page to mysql database and create a table of given name in the specified database. Create a database : First create a database
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt...."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt...."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
Create Table in Database
. In this Tutorial, we are using MySQL command query to create a table in database name... Create Table in Database   ... Tables. The Tables contain the information on data for the database. Each Table
Creating Database Tables and Indexes
Creating Database Tables and Indexes   ... the allowable syntax for identifiers in MySQL. The identifiers are Database, table, index...; Database 64 table 64 column 64 Index 
Setting up the database in PHP
will tell you how to create a database and tables in MySQL and also how... The best thing about MySQL database is that it has its own standard set up to create database which is contained tables. We can create different - different
Creating a Database in MySQL
. In this example we are going to createdatabase by MySQL and with the help... Creating a Database in MySQL       After establishing the connection with MySQL database by using
PHP Create Database
PHP Create Database To create Database in MySQL: $) Using MySQL console:ADS... set any) ADS_TO_REPLACE_2 ii)    Type create database database_name. Enter your desired database name in place of database_name e.g. create
Setting up Database with the help of PHP Scripts.
Scripts, we can also create database, table as well as insert the information. As we discussed in the last tutorial that MySQL has its own standard set up to create database which is contained tables. Let's follow the following steps to create
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
MySQL Creating and Deleting Database
CREATE USER privilege or DELETE privilege for the mysql database. The general... MySQL Creating and Deleting Database   ... and delete the database in MySQL. MySQL provides the both commands. In this section you
mysql tables - JDBC
mysql tables  hi, I have a table in MySql, having fields, emp... mangager for MySQL, statements, preparedstatements,resultset. Please can you..."); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename
Establish a Connection with MySQL Database
coding methods of establishing the connection between MySQL database and quartz application for updating and manipulating the data of MySQL database tables. Here... Establish a Connection with MySQL Database   
Map Java Objects with Database tables
Map Java Objects with Database tables  How to map Java Objects with Database tables?   First write Java domain objects ie. beans with setter and getter methods. Then map java class to table and database columns to Java
Purge Data from Mysql tables
Purge Data from Mysql tables  Hi, i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data. CREATE DEFINER=`root`@`localhost
create the SQL tables from an XML schema
create the SQL tables from an XML schema  I'm using Eclipse, Please let me know if anyone developped an application that would automatically create the SQL tables from an XML schema
Join tables in the specific database
Join tables in the specific database   ... and tables in a database. Now to retrieve a particular row from a table... two or more tables in a specific database. For this you need to have two
MySQL Create Table
MySQL Create Table       Here, you will read the brief description about the MySQL create table. The CREATE TABLE statement is used for creating a table in database
update mysql database
update mysql database  update mysql database
Mysql Join 3 Tables
Mysql Join 3 Tables       Mysql Join 3 Tables is used to join 3 Tables using left join... The Tutorial illustrate an example from 'Mysql Join 3 Tables' using Left Join
how to do two database tables in one page?
how to do two database tables in one page?  dear all: i want to show these two database tables in one page. one table on the left (dbtable.jsp... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); Statement st
Create a database
Create a database       In this section, we will teach you to create a database.  First of all... database. Then create a database using the given syntax and give the suitable name
Database - mysql - SQL
Database - mysql size limit  What is the size limit for any mysql database
Create Database SQLite
Create Database SQLite  Hi, I am unable to create database in sqlite... it on Desktop and i add the table into my project. Create Table into MSQLite Database... of all open the MSQLite database and from top menu item's choose File->New
How do you map Java Objects with Database tables?
How do you map Java Objects with Database tables?  Hi, How do you map Java Objects with Database tables? thanks
insert images into a Mysql database
insert images into a Mysql database  How can I insert images into a Mysql database
XML parsing to Mysql database
XML parsing to Mysql database  Can someone please post the code for parsing an XML file into Mysql database using SAX
what is the jsp coding to insert a data in database tables
that insert the form values to MySQL database. 1)register.jsp: <html> <form...what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my
DataBase Connectivity with MySql in Visual Web JSF Application Using Net Beans IDE
. In this application, we are going to create a database connection with mysql step...DataBase Connectivity with MySql in Visual Web JSF Application Using Net Beans...;  This Application illustrates how to create database
MySql database - SQL
to retrieve the data from Ms-access then you create a database , table and create a connection with this. Then you retrieve the data from the database. Thanks...MySql database  hello sir, i am trying to write a code which should
SQL All Tables
; SQL All Tables is used to show all the tables in database. Understand... the tables in database 'komal'. show tables : This is used to show the list of tables in database.  ADS_TO_REPLACE_2 Query mysql>

Ads