List of Topics:
Location Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Run a MySQL Database Inside a Docker Container and Create a Database Within It?

Docker

Condition for Run a MySQL Database Inside a Docker Container and Create a Database Within It

  • Description:
    This task helps you to deploy a MySQL database server using Docker. You will run a MySQL container, connect to it, and create your own database inside the running container. Docker makes running databases easy without installing MySQL directly on your system.

Steps

  •  Step 1 — Run a MySQL Container
     Description: Start a MySQL database server as a background container with root password and port mapping.
     Command:
    docker run -d --name mygurudb -e MYSQL_ROOT_PASSWORD=admin -p 3307:3306 mysql
                
     --name mygurudb → container name
     -e MYSQL_ROOT_PASSWORD=admin → set root password
     -p 3307:3306 → access MySQL on port 3307
     Result: MySQL server is running on http://localhost:3307
  •  Step 2 — Verify Container Status
     Description: Check whether the MySQL container started successfully.
     Command:
    docker ps
                
  •  Step 3 — Access MySQL Terminal Inside Container
     Description: Log into MySQL server inside the container.
     Command:
    docker exec -it mygurudb mysql -u root -p
                
     Enter password when prompted → admin
     Result: You are inside MySQL prompt.
  •  Step 4 — Create a Database
     Description: Create a new database and verify it.
     Commands inside MySQL:
    CREATE DATABASE guruDB;
    SHOW DATABASES;
                
  •  Result:
    guruDB appears in the list of databases.
Screenshots
  • 351
  • 352
  • 353
  • 354
  • 355