Linux配置部分:
(base) [root@VM-16-5-centos ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
a330b6cecb98: Pull complete
9c8f656c32b8: Pull complete
88e473c3f553: Pull complete
062463ea5d2f: Pull complete
daf7e3bdf4b6: Pull complete
1839c0b7aac9: Pull complete
cf0a0cfee6d0: Pull complete
1b42041bb11e: Pull complete
10459d86c7e6: Pull complete
b7199599d5f9: Pull complete
1d6f51e17d45: Pull complete
50e0789bacad: Pull complete
Digest: sha256:99e0989e7e3797cfbdb8d51a19d32c8d286dd8862794d01a547651a896bcf00c
Status: Downloaded newer image for mysql:latest
(base) [root@VM-16-5-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 0716d6ebcc1a 5 days ago 514 MB
postgis/postgis latest d6235d191075 11 months ago 490 MB
postgres latest 817f2d3d51ec 11 months ago 314 MB
(base) [root@VM-16-5-centos ~]# docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=your_password_about_mysql -d mysql
e4c8ff1c8d6e105e86e4c5e439329352c010d54a0c558f1d1fc2c53c266bbf4d
(base) [root@VM-16-5-centos ~]# docker exec -it mysql /bin/bash
root@e4c8ff1c8d6e:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE DATABASE test;
Query OK, 1 row affected (0.01 sec)
mysql> USE test;
Database changed
mysql> CREATE TABLE `user` (
-> `id` int(11) NOT NULL AUTO_INCREMENT,
-> `name` varchar(45) DEFAULT NULL,
-> PRIMARY KEY (`id`)
-> )
->
-> ;
Query OK, 0 rows affected, 1 warning (0.03 sec)
mysql> describe user;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(45) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> ^C
mysql> ^C
mysql> ^DBye
root@e4c8ff1c8d6e:/# ^C
root@e4c8ff1c8d6e:/# ^C
root@e4c8ff1c8d6e:/# exit
(base) [root@VM-16-5-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME S
e4c8ff1c8d6e mysql "docker-entrypoint..." 6 minutes ago Up 6 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysq l
e0cd764d915e postgis/postgis "docker-entrypoint..." 26 hours ago Up 26 hours 0.0.0.0:5432->5432/tcp post gis
Linux使用部分:
(base) [root@VM-16-5-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4c8ff1c8d6e mysql "docker-entrypoint..." 3 hours ago Up 3 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
e0cd764d915e postgis/postgis "docker-entrypoint..." 29 hours ago Up 29 hours 0.0.0.0:5432->5432/tcp postgis
(base) [root@VM-16-5-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 0716d6ebcc1a 5 days ago 514 MB
postgis/postgis latest d6235d191075 11 months ago 490 MB
postgres latest 817f2d3d51ec 11 months ago 314 MB
(base) [root@VM-16-5-centos ~]# docker exec -it mysql /bin/bash
root@e4c8ff1c8d6e:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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 |
+--------------------+
| Gadaite |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use Gadaite;
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> show tables;
+-------------------+
| Tables_in_Gadaite |
+-------------------+
| DJIA_table |
| RedditNews |
+-------------------+
2 rows in set (0.00 sec)
mysql> select count(*) from `DJIA_table`
-> ;
+----------+
| count(*) |
+----------+
| 1989 |
+----------+
1 row in set (0.04 sec)
mysql> ^DBye
root@e4c8ff1c8d6e:/# exit
(base) [root@VM-16-5-centos ~]#
dbeaver: