Detailed explanation of Deepin using docker to install mysql database

Detailed explanation of Deepin using docker to install mysql database

Query the MySQL source first

docker search mysql

You can also go to the official website to view the image tag and select the version you need, otherwise the latest version will be downloaded: https://hub.docker.com/_/mysql/
Then an error was reported! ! !

root@deepin-PC:/etc/apt# docker pull mysql:8.0.11
Error response from daemon: Get https://registry-1.docker.io/v2/library/mysql/manifests/8.0.11: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fmysql%3Apull&service=registry.docker.io: net/http: TLS handshake timeout

Switch to a domestic mirror source

echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"" | sudo tee -a /etc/default/docker

Restart Docker

sudo service docker restart

Try again

root@deepin-PC:/etc/docker# docker pull mysql:8.0.11
8.0.11: Pulling from library/mysql
be8881be8156: Pull complete
c3995dabd1d7: Pull complete
9931fdda3586: Pull complete
bb1b6b6eff6a: Pull complete
a65f125fa718: Pull complete
2d9f8dd09be2: Pull complete
37b912cb2afe: Pull complete
90a9e6fd6a27: Pull complete
959ebd3ef120: Pull complete
5eda665eddc4: Pull complete
d9007173a367: Pull complete
239f4d989075: Pull complete
Digest: sha256:ffa442557c7a350939d9cd531f77d6cbb98e868aeb4a328289e0e5469101c20e
Status: Downloaded newer image for mysql:8.0.11
docker.io/library/mysql:8.0.11

Verify

root@deepin-PC:/etc/docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 8.0.11 5dbe5b6313e1 21 months ago 445MB

Create a folder dedicated to mysql for docker

root@deepin-PC:/etc/docker# cd /opt/
root@deepin-PC:/opt# mkdir mysql_docker
root@deepin-PC:/opt# cd mysql_docker/
root@deepin-PC:/opt/mysql_docker# echo $PWD
/opt/mysql_docker

Start the mysql container

docker run --name mysqlserver -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d -i -p 3306:3306 mysql:8.0.11

View the complete container ID

cd /var/lib/docker/containers/

View the started container

root@deepin-PC:/opt/mysql_docker# docker ps 
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f9aa5b79b6a mysql:latest "docker-entrypoint.s…" About a minute ago Up 59 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp mysql

Enter mysql (you can replace mysql with the container id)

docker exec -it mysql bash


Connect to mysql

mysql -u root -p 123456

Grant remote access permission

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
5 rows in set (0.00 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

View the docker log:

root@deepin-PC:/opt/mysql_docker# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f9aa5b79b6a mysql:latest "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
root@deepin-PC:/opt/mysql_docker# docker logs -f --tail 10 1f9aa5b79b6a
2020-05-11 14:14:30+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2020-05-11T14:14:30.702850Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-05-11T14:14:30.702952Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) started as process 1
2020-05-11T14:14:30.712787Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-11T14:14:31.064937Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-05-11T14:14:31.191792Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-05-11T14:14:31.284386Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-11T14:14:31.292565Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2020-05-11T14:14:31.312549Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.

Some common operations

First check the container id

docker ps -a

Find the id

The following id is the container id

Shutdown mysql

docker stop id

Restart

docker restart id

start up

docker start id

**Shut down docker**

systemctl stop docker

Restart Docker

systemctl restart docker

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to install mysql database in deepin 2014 system
  • Deepin20.1 system installs MySQL8.0.23 (super detailed MySQL8 installation tutorial)

<<:  Analysis of MySQL user management operation examples

>>:  Vue+Openlayer batch setting flash point implementation code (based on postrender mechanism)

Recommend

MySQL 5.7.17 latest installation tutorial with pictures and text

mysql-5.7.17-winx64 is the latest version of MySQ...

Mysql accidental deletion of data solution and kill statement principle

mysql accidentally deleted data Using the delete ...

Detailed explanation of how to configure static IP in Centos8

After installing centos 8, the following error wi...

JavaScript to achieve JD.com flash sale effect

This article shares the specific code of JavaScri...

How to use the EXPLAIN command in SQL

In daily work, we sometimes run slow queries to r...

Complete list of CentOS7 firewall operation commands

Table of contents Install: 1. Basic use of firewa...

Native JS to achieve blinds special effects

This article shares a blinds special effect imple...

About the role of meta in HTML (collected and sorted from the Internet)

W3Cschool explains it this way The <meta> el...

Common writing examples for MySQL and Oracle batch insert SQL

Table of contents For example: General writing: S...

Detailed explanation of slots in Vue

The reuse of code in vue provides us with mixnis....

Docker deploys Mysql, .Net6, Sqlserver and other containers

Table of contents Install Docker on CentOS 8 1. U...

XHTML tags that are easily confused by the location of the use

<br />We have always emphasized semantics in...

Gradient slide effect implemented by CSS3

Achieve results Code html <div class="css...

The difference between Input's size and maxlength attributes

I recently used the input size and maxlength attri...