docker(三)MySQL部署

docker 部署mysql数据库

拉取镜像

docker pull mysql

查看是否镜像拉取成功

docker images
[root@sulong ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
mysql        latest    4f06b49211c0   3 days ago   530MB

为启动容器做准备

创建相对应的容器卷(我的目录是下面这样的)

[root@sulong mysql]# pwd
/home/data/mysql
[root@sulong mysql]# ll
total 16
drwxr-xr-x 3 root             root 4096 Feb 27 16:33 conf
drwxr-xr-x 7 systemd-coredump root 4096 Feb 27 16:41 data
drwxr-xr-x 2 root             root 4096 Feb 27 16:33 logs
drwxr-xr-x 2 root             root 4096 Feb 27 16:33 my.cnf
[root@sulong mysql]# 

启动容器命令

docker run --restart=always --privileged=true  
-v /home/data/mysql/data/:/var/lib/mysql 
-v /home/data/mysql/logs/:/var/log/mysql 
-v /home/data/mysql/conf:/etc/mysql/conf 
-v /home/data/mysql/my.cnf:/etc/mysql/my.cnf  
-p 33061:3306 --name mysql 
-e MYSQL_ROOT_PASSWORD=2445959102sx -d mysql

查看启动日志

docker logs [容器id或者容器的名称]
[root@sulong my.cnf]# docker logs mysql
2023-02-27 09:11:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
2023-02-27 09:11:11+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-02-27 09:11:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2023-02-27T09:11:11.678554Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-02-27T09:11:11.680481Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32) starting as process 1
2023-02-27T09:11:11.688035Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-27T09:11:12.248075Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-27T09:11:12.583054Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-02-27T09:11:12.583094Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-02-27T09:11:12.588066Z 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.
2023-02-27T09:11:12.617632Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2023-02-27T09:11:12.617688Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock

Navicat链接测试
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值