Skip to content

Latest commit

 

History

History
110 lines (78 loc) · 1.47 KB

Mariadb.md

File metadata and controls

110 lines (78 loc) · 1.47 KB

MariaDB with Docker

Start shell of MySQL

Use bellow command

docker-compose exec mysql bash 

Connect to MySQL bash

  1. Get container name of mysql
docker-compose ps 
# Result : crazytest-mariadb-1

Explore your MariaDB database

1. Connect to database as admin

docker exec -it crazytest-mariadb-1 mysql -p

2. Connect to MySql (Mariadb)

Execute the command below :

You can found the password into the docker-compose.ymlif you are using docker compose

mysql -u root -p

3. Show all databases

Execute the command below :

SHOW DATABASES;

Result :

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| crazy_db           |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+

4. Select database to explore

Execute the command below :

USE crazy_db;

Result :

Database changed
MariaDB [crazy_db]> 

5. Show all tables

Execute the command below :

SHOW TABLES;

Result :

MariaDB [crazy_db]> SHOW TABLES;
+--------------------+
| Tables_in_crazy_db |
+--------------------+
| Booking            |
+--------------------+

6. Delete table

Execute the command below :

DROP TABLE {table};

Result :

Query OK, 0 rows affected

5. Show all tables

Get schema of one table

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Booking';