How To Create Database and Table In MySQL and MariaDB

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-create-database-and-table-in-mysql-and-mariadb/
PINTEREST
PINTEREST
INSTAGRAM

MySQL database is very popular database server used by a lot of small and big companies. In this tutorial we will look the basics of MySQL server like creating database and tables, populating data into tables. MySQL installation can be done with the following tutorial for Linux operating systems.

How to Install Mariadb/Mysql Server in Linux Fedora?

Following operations can be done in MariaDB without any problem. MariaDB is the fork of the MySQL database and it is compatible with MySQL.

Connect To MySQL Database

There are different tools to manage MySQL servers. We can use  GUI tools like MySQL tools, Heidi, Toad or command line tools provided by MySQL package. In this tutorial we will use command line tools provided by MySQL. First we use mysql command to connect database

Connect To MySQL Database

Connect To MySQL Database

List Databases

Before creating a database listing existing databases is beneficial. So we can get list of existing databases and their names.

List Databases

List Databases

Create Database

We will create database but we should chose a different name from existing databases as we listed previous step. We will use create database command for database creation by providing database name. In the example we create a database named person .

Create Database

Create Database

Select Database

After database creation we will create a table. But we should select database to associate the table with the database. Otherwise the table creation will fail because of no database is selected.

LEARN MORE  Backup and Restore MySQL Databases With Mysqldump In Linux

Select Database

Select Database

Create Table

Now most important part we will create a table by giving related columns. We will use CREATE TABLE command with the related column names. In this example we will create table named persons with fields id , name , surname .

Create Table

Create Table

Insert Data Into Table

We will insert single row or record with the INSERT INTO sql. We will insert following values;

  • id 1
  • name poftut
  • surname com

Insert Data Into Table

Insert Data Into Table

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-create-database-and-table-in-mysql-and-mariadb/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)