Use and configuration of the Docker version of MySQL (1) basic operation of--docker

Source: Internet
Author: User
Tags mysql version docker run

Recently really busy as a dog, other content, such as a little idle to update together.

This article is mainly about the use and configuration information of the Docker version of MySQL. Because the internship company needs to engage in a docker test environment, it also needs to include basic dependencies. Most importantly, because this docker is used as the slave of Jenkins, it may not be possible to add parameters at startup. This leads me to go through the entire use and configuration of the Docker version of MySQL to see if there is a setup method that replaces the startup parameters.

The basic information about MySQL is described in the following links:

https://hub.docker.com/r/mysql/mysql-server/

Https://github.com/mysql/mysql-docker

The article omits the installation of Docker. It's good to have a look on the website.

So Lin can die of big special.

1. General basic use of the Docker version of MySQL (Docker basic operation):

Download (version community):

Docker Pull Mysql/mysql-server:tag

The tag here refers to the MySQL version number, such as 5.5~5.7,8.0,latest.

Docker images

This is the list that is used to view the current image.

Docker Run--name=mysql1-d Mysql/mysql-server:tag

The next step is to run the image, which is probably the most basic running statement.

--name the name of the container (container) that runs the image. If not declared, a random one is generated.

followed by the name of the mirror.

-d means that the operation of a mirror is thrown in the background.

Ps

You can use this statement to see how the current image is running.

The whole process is simply: pull image, run image, PS to see if the image is up.

Docker logs MYSQL1

Logs with the name of the container, you can see the log information that this container generates when it runs the image. If PS sees that the mirror does not run properly, it can be logs checked.

Docker exec-it MYSQL1 Mysql-uroot-p

exec is performing the subsequent operations in the mirror, such as Mysql-uroot-p.

To make it easier to execute bash commands in the image, you can also execute a bash with this command.

Docker Stop MYSQL1

This will stop the container from running. Want to delete container first to stop container. You want to delete the image first to delete container. Anyway, it's tied up.

2. The difference between the Docker version of MySQL and the normal version of MySQL

Docker images for MySQL is optimized for code size, which means they only include crucial components that is expected to Being relevant for the majority of users of the "who run" MySQL instances in Docker containers.

According to the official website, the Docker version of MySQL contains only the necessary parts. The list is as follows:

/usr/bin/my_print_defaults/usr/bin/mysql/usr/bin/mysql_config/usr/bin/mysql_ install_db/usr/bin/mysql_tzinfo_to_sql/usr/bin/mysql_upgrade/usr/bin/mysqladmin /usr/bin/mysqlcheck/usr/bin/mysqldump/usr/bin/mysqlpump/usr/sbin/mysqld

3. Use of the Docker version of MySQL

The method for viewing log is mentioned earlier. The default configuration for the Docker version of MySQL is that the first root password is randomly generated. So to log in with the root account, first check the randomly generated password.

2>&1grep  generatedgenerated ROOT password:axegh3kajydlarubemecis& Eshos

Then you can log in-uroot-p.

The first thing to do after logging in is to change the root password.

' Root '@'localhost'password';

The rest is almost the same as running MySQL locally.

Note that we have just run Docker's command and did not map the ports in Docker and the ports on this computer. So although MySQL is started, it cannot be accessed through 3306 or other ports.

If you want to be in the same machine, you need to map Docker and native ports when you start the Docker container.

Docker Run-p Ip:hostPort:containerPort

Use and configuration of the Docker version of MySQL (1) basic operation of--docker

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.