Home Website Tutorials MySQL/MariaDB database management commands.

MySQL/MariaDB database management commands.

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

I. OVERVIEW

Most of us are used to managing MySQL/MariaDB databases through the phpMyAdmin tool. In fact, the phpMyAdmin tool is so popular that users can quickly and efficiently manage databases through an intuitive interface. But if your server doesn’t install phpMyAdmin, how to manage the database?

In today’s article, AZDIGI will guide you through simple database management with the most commonly used operations. Let’s do it together with AZDIGI.

II. DATABASE MANAGEMENT OPERATIONS

1. Log in to MariaDB

First, you need to log in to MySQL/MariaDB with the root user.

You enter the syntax mysql -u root -p then MySQL will ask you to enter the password of MySQL. This is the highest password that manages the entire database.

AZDIGI Tutorial
mysql -u root -p
    
MySQL/MariaDB database management commands.

2. Create a database

To create the database, you enter the following line: Note:

  • CREATE DATABASE: Command to create the database
  • database1: The name of the database to create, please change it with the name you need to create
AZDIGI Tutorial
MariaDB [(none)]> CREATE DATABASE database1;
    
MySQL/MariaDB database management commands.

3. Create User Password

To create User and Password for the user, enter the command line below:

  • CREATE USER: Command to create user
  • database1: Username, please replace it with your username
  • IDENTIFIED BY ‘my-password’: Replace my-password with the password you need to set
AZDIGI Tutorial
MariaDB [(none)]> CREATE USER 'database1'@'localhost' IDENTIFIED BY 'my-password';    
CleanShot 2020 10 22 at 12.00.38

4. Assign permissions to User Database

Once you’ve created the database and user, you’ll need to assign permissions to execute queries. To assign permissions, you use the following syntax:

AZDIGI Tutorial
MariaDB [(none)]> GRANT ALL PRIVILEGES ON database1.* TO 'database1'@'localhost';
CleanShot 2020 10 22 at 12.01.45

5. Show Database

To show all databases, you use the show databases command. With this command, you will see all the existing databases.

AZDIGI Tutorial
MariaDB [(none)]> MariaDB [(none)]> show databases;
CleanShot 2020 10 22 at 12.02.22

6. Access to the database

To access a database, You use the use database-name command .

AZDIGI Tutorial
MariaDB [(none)]> use database1;

7. Show the database table

AZDIGI Tutorial
MariaDB [database1]> show tables;
CleanShot 2020 10 22 at 12.06.01

III. Summary

Hopefully, this article will help you get familiar with database administration using the command line, don’t depend on interfaces anymore and confidently manage your servers securely.

If you have questions or need support, please live chat with Technical Department. Or send the ticket to the Technical Department according to the information below.

  • Hotline 247: 028 888 24768 (Ext 0)
  • Ticket/Email: You can use your email to register for the service and send it directly to: support@azdigi.com

The article is still updating on MySQL/MariaDB database management!

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign