Getting Started with MariaDB

In our previous post, we demonstrated steps to install MariaDB Server on Ubuntu, in this article, we are going to show how to create database in MySQL/MariaDB. We are going to talk about DDL(Data Definition Language), how to create tables and authorize users to access them.

Start your mariadb-server and follow the steps

Creating Databases, Tables, and Authorized Users

Step 1: Connect to your mariadb-server and run below sql. This can be done via mysql client or any other tools like Heidisql, phpmyadmin etc. This is going to create a new database in your server. 
CREATE DATABASE myFirstDB;
Check if the database already exists and create
CREATE DATABASE IF NOT EXISTS myFirstDB;
To list all the databases in a server.
SHOW DATABASES;
To connect to your database
USE DATABASE_NAME;
Once you have selected your database, use following to create user
CREATE USER 'username'@'localhost' IDENTIFIED BY 'user_password';
To create a user that can connect from any host, use the '%' wildcard as a host part:
CREATE USER 'username'@'%' IDENTIFIED BY 'user_password';
No you can login to your MariaDB using the new user and password
mysql -h localhost -P port -u username -p user_password 

No comments:

Running Total In SQL Server

Running total refers to the sum of values in all cells of a column that precedes the next cell in that particular column. Using Window Funct...