Use Docker to build MySQL step memo under Ubuntu

Source: Internet
Author: User
Tags ssh port

Docker install and pull MySQL image is not introduced here, many introductions, recommended to go to the official Docker website to view.

This article mainly introduces some configuration of MySQL container after running.

Before you look down, make sure

Ls

You can see the MySQL container.

[1] If the database schema is not on the server, SCP service is available, only the schema of a file, the fastest way to profile is

SCP -P port/path/to/local/file [email protected]:/path/to/save/the/file

Generally for security reasons you will not use the default 23 port number to open the SSH service, right (: P)

Here-P is the parameter to set the custom SSH port number

After the schema has been uploaded to the host server, it cannot be used directly in the container.

Need to use Docker's CP command to transfer files

CP /path/to/host/file containerid:/path/to/save/file

Containerid can be used

Ls

View, the container ID is a long string of numeric letters in the combination of the hash value, generally only need to enter the previous 5-7 bits enough to distinguish the other ID is possible.

This command can also see container name, which is generally more readable, and can be replaced with container name instead of the container ID above

You can then import the schema with a SQL file, similar to the command

Mysql-hhost-u User-p Database < Schema.sql

Host is the IP of MySQL container, or it can be container name,ip can be used

Docker container Inspect Containerid

View, here Containerid can also be replaced with container name.

First import, mysql instance may not have to create the database, then you need to log on to MySQL to create a database.

Mysql-hhost-u user-p

Then enter the password, login, see here people should know, here enter the password is not echo * * * RIGHT (: P)

mysql> CREATE database;

This creates the database successfully, followed by subsequent import scripts

mysql> usedatabase;mysql>show tables;

When you see the table that the schema expects to create, it's over.

Reference: [1] using SCP remote upload download File/folder

[2] Running SQL files in Docker

[3]ubuntu connection MySQL detailed steps

Use Docker to build MySQL step memo under Ubuntu

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.