CentOS 下的 Docker 配置仓库和安装mysql5.7

[root@localhost etc]# vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://3laho3y3.mirror.aliyuncs.com"]
}
~
~

~
"docker/daemon.json" 3L, 67C written
[root@localhost etc]# systemctl daemon-reload
[root@localhost etc]# systemctl restart docker
[root@localhost etc]# docker pull mysql:5.7
Trying to pull repository docker.io/library/mysql ... 
5.7: Pulling from docker.io/library/mysql
619014d83c02: Pull complete 
9ced578c3a5f: Pull complete 
731f6e13d8ea: Pull complete 
3c183de42679: Pull complete 
6de69b5c2f3c: Pull complete 
00f0a4086406: Pull complete 
84d93aea836d: Pull complete 
e2dd1f3e5a3d: Pull complete 
98fb37478ee6: Pull complete 
57eb21662ebf: Pull complete 
e95057f0a050: Pull complete 
Digest: sha256:cf6899e980c38071a78ded028de40e65286bfbbb746b97617ac4c9a84c4e812d
Status: Downloaded newer image for docker.io/mysql:5.7
[root@localhost etc]# 
[root@localhost etc]# docker run -itd -p 0.0.0.0:3307:3306 -P docker.io/mysql:5.7 bash
e39d8a6d7ec1a654acd1bd78e7bbde6f4d53136934210210dba4fe0531be247c
[root@localhost etc]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                          PORTS                                              NAMES
e39d8a6d7ec1        docker.io/mysql:5.7   "docker-entrypoint..."   2 seconds ago       Up 1 second                     0.0.0.0:3307->3306/tcp, 0.0.0.0:32771->33060/tcp   sad_einstein
[root@localhost etc]# docker exec -it sad_einstein bash
root@e39d8a6d7ec1:/# service mysql status
[info] MySQL Community Server 5.7.29 is not running.
root@e39d8a6d7ec1:/# service mysql start
No directory, logging in with HOME=/
2020-02-02T13:32:09.362492Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-02-02T13:32:09.905779Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-02-02T13:32:09.971187Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-02-02T13:32:09.979450Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 69d485a0-45c0-11ea-b357-0242ac110002.
2020-02-02T13:32:09.980341Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-02-02T13:32:10.833825Z 0 [Warning] CA certificate ca.pem is self signed.
2020-02-02T13:32:11.199597Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
No directory, logging in with HOME=/
..
[info] MySQL Community Server 5.7.29 is started.
root@e39d8a6d7ec1:/# service mysql stop
...
[info] MySQL Community Server 5.7.29 is stopped.
root@e39d8a6d7ec1:/# usermod -d /var/lib/mysql/ mysql^C
root@e39d8a6d7ec1:/# ls -lD /var/lib/mysql/
  total 110668
  -rw-r-----. 1 mysql mysql       56 Feb  2 13:32 auto.cnf
  -rw-------. 1 mysql mysql     1676 Feb  2 13:32 ca-key.pem
  -rw-r--r--. 1 mysql mysql     1112 Feb  2 13:32 ca.pem
  -rw-r--r--. 1 mysql mysql     1112 Feb  2 13:32 client-cert.pem
  -rw-------. 1 mysql mysql     1680 Feb  2 13:32 client-key.pem
  -rw-r-----. 1 mysql mysql     8116 Feb  2 13:32 e39d8a6d7ec1.err
  -rw-r-----. 1 mysql mysql      302 Feb  2 13:32 ib_buffer_pool
  -rw-r-----. 1 mysql mysql 50331648 Feb  2 13:32 ib_logfile0
  -rw-r-----. 1 mysql mysql 50331648 Feb  2 13:32 ib_logfile1
  -rw-r-----. 1 mysql mysql 12582912 Feb  2 13:32 ibdata1
  drwxr-x---. 2 mysql mysql     4096 Feb  2 13:32 mysql
  drwxr-x---. 2 mysql mysql     8192 Feb  2 13:32 performance_schema
  -rw-------. 1 mysql mysql     1676 Feb  2 13:32 private_key.pem
  -rw-r--r--. 1 mysql mysql      452 Feb  2 13:32 public_key.pem
  -rw-r--r--. 1 mysql mysql     1112 Feb  2 13:32 server-cert.pem
  -rw-------. 1 mysql mysql     1680 Feb  2 13:32 server-key.pem
  drwxr-x---. 2 mysql mysql     8192 Feb  2 13:32 sys
//DIRED// 65 73 124 134 185 191 242 257 308 322 373 389 440 454 505 516 567 578 629 636 687 692 743 761 812 827 878 892 943 958 1009 1023 1074 1077
//DIRED-OPTIONS// --quoting-style=literal
root@e39d8a6d7ec1:/# ls -lD /var/lib/mysql/^C                                                                                                                             
root@e39d8a6d7ec1:/# /var/lib/mysql/^C
root@e39d8a6d7ec1:/# usermod -d /var/lib/mysql/ mysql
root@e39d8a6d7ec1:/# service mysql start
..
[info] MySQL Community Server 5.7.29 is started.
root@e39d8a6d7ec1:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

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> update user set authentication_string = password('root') where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> 

 

你可能感兴趣的:(Docker,docker,mysql,仓库)