BookStore Docker 2 : MySQL monitoring
Docker Basic Reference Link
Without running Docker Desktop

check docker status
docker ps

Run Docker using Docker or cmd


cmd : To start stopped docker
docker start <container name>
==> based on this
docker start mysql-container
docker ps : check status

Stop a running container on Desktop or cmd

docker stop <container_name_or_id>
==> Based on above
docker stop mysql-container

Connect to the MySQL instances
Run the following command:
docker exec -it mysql-container mysql -u root -p
When password prompted -> Enter your password that you set for creating container

Connect to MySQL instnace running on your local machine at IP '127.0.0.1'
mysql -h 127.0.0.1 -P 13306 -u root -p


MySQL Monitoring
Summary of Commands
List Databases:
SHOW DATABASES;Create Database:
CREATE DATABASE mydatabase;Use Database:
USE mydatabase;Create Table:
CREATE TABLE mytable (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL);Insert Data:
INSERT INTO mytable (name) VALUES ('John Doe');Query Data:
SELECT * FROM mytable;Exit MySQL Monitor:
EXIT;
Now that you're connected to the MySQL monitor, you can perform various database operations. Here are some common commands to help you get started:
1. Check Existing Databases
To list all databases:
SHOW DATABASES;

2. Create a New Database
To create a new database:
CREATE DATABASE TestDataBase;

3. Use a Database
To switch to a specific database:
USE TestDataBase;

4. Create a New Table
To create a new table within the selected database (TestDataBase):
CREATE TABLE mytable (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);

5. Insert Data into a Table
To insert data into a table:
INSERT INTO mytable (name) VALUES ('John Jeong');

6. Query Data from a Table
To query data from a table:
SELECT * FROM mytable;

7. Exit MySQL Monitor
To exit the MySQL monitor:
EXIT;
