Ubuntu16.04 MySQL server installed with docker

1. Find the mysql mirrors on Docker Hub

sudo docker search mysql

Ubuntu16.04 MySQL server installed with docker

2. Pull the official image

sudo docker pull mysql

Ubuntu16.04 MySQL server installed with docker

3. Check the image information

sudo docker imagesUbuntu16.04 MySQL server installed with docker

4. Use of the container run mysql mirror

sudo docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest

Ubuntu16.04 MySQL server installed with docker

5. Check the vessel to start

sudo docker ps

Ubuntu16.04 MySQL server installed with docker

6.docker mysql installation has been completed

Here is the MySQL open container of execution called mysqldb

sudo docker start mysqldb
sudo docker exec -it mysqldb /bin/bash

Ubuntu16.04 MySQL server installed with docker

Ubuntu16.04 MySQL server installed with docker

7. Close the container mysqldb

sudo docker stop mysqldb

8. command to connect

mysql -u root -p

9. Exit

exit

note:

After installation is complete docker command not found at this time do not worry
first Linux server can be used to reopen closed up
then you will find mysql -u root -p command mysql connection will be a mistake
to say that the file can not be found

Ubuntu16.04 MySQL server installed with docker

Input:

mysql -u root -h 127.0.0.1 -p

Ubuntu16.04 MySQL server installed with docker

Specify what address, so that you can go up connection
if you add -h127.0.0.1 you can log database, indicating that the database is running.
Find mysql.sock by the find command file, find the file does not exist, and my understanding is that mysql generated files when failed, this is not the focus of our research

Guess you like

Origin blog.51cto.com/14418066/2413586