zoukankan      html  css  js  c++  java
  • 转载:docker 安装MySQL远程连接(阿里云服务器)

    docker 安装MySQL远程连接(阿里云服务器)

    用Navicat连接本机Docker的Mysql 和一些问题

    1. 下载Mysql的Docker镜像

    [plain] view plain copy
     
     
     
     
    1. $ docker search mysql (搜索mysql镜像)  
    2. $ docker pull mysql (下载mysql镜像,默认最新版本)  

    2. 运行镜像,设置root账号初始密码(123456),映射本地宿主机端口3306到Docker端口3306。测试过程没有挂载本地数据盘:

    [plain] view plain copy
     
     
     
     
    1. $ docker run -it --rm --name mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql  

    3. 查看已运行的容器:

    [plain] view plain copy
     
     
     
     
    1. $ docker ps -a  
    2. CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES  
    3. a42f31094df5        mysql               "docker-entrypoint.s…"   7 seconds ago       Up 6 seconds        0.0.0.0:3306->3306/tcp   mysql  

    4. 进入mysql容器:

    [plain] view plain copy
     
     
     
     
    1. docker exec -it mysql bash  
    2. root@a42f31094df5:/#   

    5. 在容器内登陆Mysql:

    [sql] view plain copy
     
     
     
     
    1. root@a42f31094df5:/# mysql -uroot -p123456 或 (mysql -uroot -p ) 
    2. mysql: [Warning] Using a password on the command line interface can be insecure.  
    3. Welcome to the MySQL monitor.  Commands end with ; or g.  
    4. Your MySQL connection id is 9  
    5. Server version: 8.0.11 MySQL Community Server - GPL  
    6.   
    7. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.  
    8.   
    9. Oracle is a registered trademark of Oracle Corporation and/or its  
    10. affiliates. Other names may be trademarks of their respective  
    11. owners.  
    12.   
    13. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  
    14.   
    15. mysql>   

    6. 查看用户信息

    [html] view plain copy
     
     
     
     
    1. mysql> select host,user,plugin,authentication_string from mysql.user;    
    2. +-----------+------------------+-----------------------+------------------------------------------------------------------------+  
    3. | host      | user             | plugin                | authentication_string                                                  |  
    4. +-----------+------------------+-----------------------+------------------------------------------------------------------------+  
    5. | %         | root             | caching_sha2_password | $A$005$^]RQB}j~t!      .#v)3.UogPRFu8VJA5/GKEbK5edEQlMT5sHw2n72zYJNlIbo3 |  
    6. | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
    7. | localhost | mysql.session    | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
    8. | localhost | mysql.sys        | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE                              |  
    9. | localhost | root             | caching_sha2_password | $A$005$Y6&q!59^Fmh)@-6TG58J3F5+3I/HI9L|JCadNG+-+d6W+1D_UFW+7MRD7F3 |  
    10. +-----------+------------------+-----------------------+------------------------------------------------------------------------+  

    备注:host为 % 表示不限制ip   localhost表示本机使用    plugin非mysql_native_password 则需要修改密码

    navicat链接错误;我们继续往下看;

     
    1. mysql> ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';  
    2. Query OK, 0 rows affected (0.01 sec)  
    3. mysql>   
    4. mysql> FLUSH PRIVILEGES;  
    5. Query OK, 0 rows affected (0.01 sec)  
    6.   
    7. mysql>   

    7..连接数据库的

     

    连接成功了。

  • 相关阅读:
    Stack Overflow 2016最新架构探秘
    (转)个人职业规划中如何使自己的职业生涯升华
    (转)软件架构师应该知道的97件事
    (转)一共81个,开源大数据处理工具汇总
    (转) 架构师的能力模型
    (转)数据库表分割技术浅析(水平分割/垂直分割/库表散列)
    (转)乐观锁与悲观锁——解决并发问题
    (转)从“如何设计用户超过1亿的应用”说起—数据库调优实战
    (转)浅谈数据库的水平拆分
    (转).NET Memory Profiler 使用简介
  • 原文地址:https://www.cnblogs.com/thinkinpakho/p/10329211.html
Copyright © 2011-2022 走看看