0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Create a container from docker images 【Mysql】

Posted at

Create a Mysql Container

image.png

Pull an image from Docker Hub

terminal
    docker pull mysql

image.png

Start a mysql server instance

The following command starts another mysql container instance and runs the mysql command line client against your original mysql container, allowing you to execute SQL statements against your database instance:

terminal
    docker container run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=mydb mysql

image.png

Container shell access and viewing MySQL logs

The docker exec command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your mysql container:

terminal
    docker exec -it mysql bash

image.png

Connecting to and Disconnecting from the Server

terminal
    mysql -u root -p
    Enter password:

image.png

User infomation in mysql

terminal
    select user, host from mysql.user;

image.png

database infomation

terminal
    show databases;

image.png

stop mysql container

terminal
    docker container stop mysql
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?