zoukankan      html  css  js  c++  java
  • docker部署mysql

    1. 下载

    [root@localhost my.Shells]# ./dockerStart.sh 
    start or stop 
    start
    Redirecting to /bin/systemctl start docker.service
    [root@localhost my.Shells]# docker pull mysql
    Using default tag: latest
    Trying to pull repository docker.io/library/mysql ... 
    latest: Pulling from docker.io/library/mysql
    f49cf87b52c1: Pull complete 
    78032de49d65: Pull complete 
    837546b20bc4: Pull complete 
    9b8316af6cc6: Pull complete 
    1056cf29b9f1: Pull complete 
    86f3913b029a: Pull complete 
    f98eea8321ca: Pull complete 
    3a8e3ebdeaf5: Pull complete 
    4be06ac1c51e: Pull complete 
    920c7ffb7747: Pull complete 
    Digest: sha256:7cdb08f30a54d109ddded59525937592cb6852ff635a546626a8960d9ec34c30
    [root@localhost my.Shells]# docker images 
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    docker.io/mysql     latest              f008d8ff927d        9 days ago          408.5 MB
    docker.io/nginx     latest              3f8a4339aadd        4 weeks ago         108.5 MB
    docker.io/redis     latest              1e70071f4af4        6 weeks ago         106.7 MB

    2. 运行

    [root@localhost my.Shells]# docker run --name docker-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=wzy123 -d mysql  //用户默认是root,密码默认是root的密码
    283a1fa17fef310d9e329e11f10b8179e5be5fd88310be64fb0b4fa75ab5d80f
    [root@localhost my.Shells]# docker ps   //mysql容器已经启动了
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    283a1fa17fef        mysql               "docker-entrypoint.sh"   7 seconds ago       Up 6 seconds        0.0.0.0:3306->3306/tcp   docker-mysql

    3. 登录

    1.工具登录

    2.命令行登录
    [root@localhost my.Shells]# docker ps 
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    283a1fa17fef        mysql               "docker-entrypoint.sh"   18 hours ago        Up 3 seconds        0.0.0.0:3306->3306/tcp   docker-mysql
    [root@localhost my.Shells]# docker exec -it docker-mysql bash
    root@283a1fa17fef:/# ls
    bin  boot  dev    docker-entrypoint-initdb.d  entrypoint.sh  etc    home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
    
    root@283a1fa17fef:/# mysql -u root -p
    Enter password:   //wzy123
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 4
    Server version: 5.7.21 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, 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> 

     注意:当使用docker rm [id]后,mysql数据库的所有数据会全部清除,再重新开启一个镜像是一个崭新的数据库。

  • 相关阅读:
    sftp上传到远程服务器
    mysql 的 find_in_set函数使用方法
    wamp2.5 局域网无法访问问题
    JS图片上传预览
    select2的相关问题
    linux 更新源miss问题
    freeMarker遍历map的正确方式
    Input类型是checkbox时checked属性获取
    Java 内存区域划分 备忘录
    简单聊聊java中如何判定一个对象可回收
  • 原文地址:https://www.cnblogs.com/wwzyy/p/8351564.html
Copyright © 2011-2022 走看看