• 使用docker中mysql镜像


    1、拉取mysql镜像

    docker pull mysql:5.6

    2、运行mysql的镜像生成一个正在运行的容器,可以通过docker contain ls得到容器的id信息

    docker run -dit -p 3306:3306 mysql:5.6 bash  # 会返回容器的id,赋值前5、6位就可以了,改为5.7也一样
    docker exec -it container_id bash # 使用上面复制的容器ID前5、6位,进入容器
    # 使用uname -a查看系统为ubuntu系统
    # 查看mysql的状态
    service mysql status
    # 启动mysql
    service mysql start
    # 进入mysql客户端
    mysql
    # 添加远程访问权限,在下面语句中的*和%号的说明,不懂得话,请查看后面的参考博客
    mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
    # 在另一台电脑上使用root,123456进行登录mysql可以成功进入,需要注意防火墙的开关,我电脑默认是关闭的
    mysql> flush privileges;

    在自己搭建的时候,没有进行mysql远程访问权限设置,在另一台电脑上登录的时候报错,退出容器使用ctrl + D退出

    host 'xxx' is not allowed to connect to mysql server

    然后就参考了博客:https://www.cnblogs.com/jesu/p/5650699.html

  • 相关阅读:
    设计模式(十):Decorator装饰者模式 -- 结构型模式
    设计模式(九):Composite组合模式 -- 结构型模式
    Anagrams
    Gas Station
    Unique Binary Search Trees II
    Trapping Rain Water
    4Sum
    3Sum Closest
    3Sum
    Longest Valid Parentheses
  • 原文地址:https://www.cnblogs.com/TheoryDance/p/10326133.html
Copyright © 2020-2023  润新知