运行mysql个容器实例
-e MYSQL_ROOT_PASSWORD 设置密码
--name 设置名称
-p 宿主机和容器的端口映射
-v mysql数据目录映射到宿主机目录
docker run -d -e MYSQL_ROOT_PASSWORD=123456
-p 3306:3306
-v /data/mysql/:/var/lib/mysql
--name mysql
mysql
进入容器登录mysql服务
[root@handsometa ~]# docker exec -it mysql bash
bash-4.4# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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>