MySQL :: MySQL Installation Guide :: 7.6.1 Basic Steps for MySQL Server Deployment with Docker

MySQL :: MySQL Installation Guide :: 7.6.1 Basic Steps for MySQL Server Deployment with Docker

Warning

The MySQL Docker images maintained by the MySQL team are built specifically for Linux platforms. Other platforms are not supported, and users using these MySQL Docker images on them are doing so at their own risk. See the discussion here for some known limitations for running these containers on non-Linux operating systems.

不填写tag,直接获取最新版本的

docker pull mysql/mysql-server  这个命令,直接在cmd或者Powershell里面执行
Using default tag: latest

 

然后Docker Desktop的Images菜单里面可以看到

 

 docker images  这个命令查看images
REPOSITORY           TAG       IMAGE ID       CREATED       SIZE
mysql/mysql-server   latest    1d9c2219ff69   7 weeks ago   496MB

Starting a MySQL Server Instance

To start a new Docker container for a MySQL Server, use the following command:

docker run --name=container_name  --restart on-failure -d image_name:tag

The image name can be obtained using the docker images command, as explained in Downloading a MySQL Server Docker Image.

 

 

 docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS                   PORTS                       NAMES
2c1c9dffe6c0   mysql/mysql-server:latest   "/entrypoint.sh mysq…"   3 minutes ago   Up 3 minutes (healthy)   3306/tcp, 33060-33061/tcp   festive_leavitt

 

按照下面这个运行,这样本机和docker之间建立映射关系

 docker run -e MYSQL_ROOT_PASSWORD=root -p 3307:3307 mysql

三、将容器指定端口指定映射到宿主机的一个端口上。

例如:

docker run -p 8000:80 -it ubuntu /bin/bash

以上指令会将容器的80端口映射到宿主机的8000端口上。



作者:meieugene
链接:https://www.jianshu.com/p/b92d4b845ed6
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

 

在mysql的container的terminal里面

mysql -u root -p

show databases;  这里的冒号不能省略
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

 

MySQL :: MySQL 8.0 Reference Manual :: 4.2.4 Connecting to the MySQL Server Using Command Options

mysql --host=localhost --port=3307 -u root -p

 

 

MySQL :: MySQL 8.0 Reference Manual :: 6.2.1 Account User Names and Passwords

MySQL stores accounts in the user table of the mysql system database. An account is defined in terms of a user name and the client host or hosts from which the user can connect to the server. For information about account representation in the user table, see Section 6.2.3, “Grant Tables”.

 

 

 

cybuster:
两个container需要通信的时候需要在主动连接那侧加上 --link 容器名:别名  的参数

cybuster:
docker run -d -e PMA_ARBITRARY=1 --link charming_liskov:mysql -p 8080:80 phpmyadmin/phpmyadmin

 

posted @ 2023-03-11 12:00  ChuckLu  阅读(19)  评论(0编辑  收藏  举报