Zyngalu: Databases
Index | Home Server | Hardware | Feedback | Mount USB Drive | Shut Down Pi | Computer IP Address

MariaSQL Database

We will be using the MariaSQL database to get an understanding of how to create and maintain a databse. MariaSQL is made by the same person who created the original MySql database. Infact My and Maria are the names of his daughters.

Create a User with Permissions

Your database needs to know that you are the user, so you need to create a user and give the user a username and password.

In the terminal open a MariaSQL session

sudo mysql -u root -p

Just press enter. When asked for a password press enter again.

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 591
Server version: 10.3.23-MariaDB-0+deb10u1 Raspbian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Create a User

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Give the User Permissions

GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';

Show Databases

MariaDB [(none)]> show databases;

Show Databases

 MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| forums             |
| information_schema |
| mysql              |
| performance_schema |
| sphider_db         |
+--------------------+
5 rows in set (0.001 sec)

Delete a Database

DROP DATABASE forums; 
MariaDB [(none)]> DROP DATABASE forums;
Query OK, 69 rows affected (1.852 sec)
 MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sphider_db         |
+--------------------+
4 rows in set (0.001 sec)

Create a Database

MariaDB [(none)]> CREATE DATABASE forums

Show Databases

 MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| forums             |
| information_schema |
| mysql              |
| performance_schema |
| sphider_db         |
+--------------------+
5 rows in set (0.001 sec)