Setting Up MySQL Docker Container

1 min read
Step 1: Install Docker
Step 2: Pull the MySQL Docker Image
docker pull mysql:latest
Step 3: Run the MySQL Container
docker run --name talend-mysql -e MYSQL_ROOT_PASSWORD=your_password -e MYSQL_DATABASE=talend_db -p 3306:3306 -d mysql:latest
Step 4: Verify the MySQL Container is Running
docker ps
Step 5: Stopping and Starting the Container
docker stop talend-mysql
docker start talend-mysql
Generate dummy data for a users
table in MySQL.
Step 1: Access the database server
docker exec -it talend-mysql mysql -u root -p
Step 2: Select Database
USE talend_db;
Step 3: Create the users
Table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Step 4: Generate Dummy Data
INSERT INTO users (username, email, password) VALUES
('user1', 'user1@example.com', 'password1'),
('user2', 'user2@example.com', 'password2'),
('user3', 'user3@example.com', 'password3'),
('user4', 'user4@example.com', 'password4'),
('user5', 'user5@example.com', 'password5');
Step 5: Verify the Data
SELECT * FROM users;
0
Subscribe to my newsletter
Read articles from Mohamad Mahmood directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Mohamad Mahmood
Mohamad Mahmood
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He studies at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).