Nội dung
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.
mysql -u root -p
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
MariaDB [(none)]> CREATE DATABASE database1;
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
MariaDB [(none)]> CREATE USER 'database1'@'localhost' IDENTIFIED BY 'my-password';
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:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON database1.* TO 'database1'@'localhost';
5. Show Database
To show all databases, you use the show databases command. With this command, you will see all the existing databases.
MariaDB [(none)]> MariaDB [(none)]> show databases;
6. Access to the database
To access a database, You use the use database-name command .
MariaDB [(none)]> use database1;
7. Show the database table
MariaDB [database1]> show tables;
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!