MySQL installation + Navicat_Premium (+ mounted cracks) + Navicat_Premium in MySQL is not connected properly + localhost not connected to the starting container Docker MySQL

  • MySQL Installation

  • I installed MySQL installation here is MySQL 8.0 Command Line Client
  • Download + installation details, see https://www.cnblogs.com/taopanfeng/p/10984721.html
  • Navicat_Premium installation + crack

  • Navicat_Premium installation + crack (the easiest) link: https://pan.baidu.com/s/1Iiz9BGf88dmyOnpcf9fUKA extraction code: 8tds

  • Installation Instructions: Install good [navicat111_premium_cs_x64.exe] After that, find the directory of the installation, use [navicat.exe] to replace the installed files to run

  • localhost on MySQL can not connect properly

  •  About local connection can not be normal
    1251 - Client does not support authentication protocol required by server; consider upgrading MySQL client

     

     

    Connection name: local connection 
    
    host name or IP address: localhost 
    
    port: 3306 
    
    username: root 
    
    password: 123456
  • Input not connected, then the above specific solution is as follows:
    1. First, configure the environment variables
    2.  

    3.  

    4.  

    5.  

    6.  

    7.  

    8. Windows + R to open the Run, enter cmd carriage return
    9.  

    10. 依次输入
      mysql -u root -p
      
      输入密码 我这里输入 123456
      
      这里如果密码不是 123456 就换成你的密码
      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
      
      刷新
      FLUSH PRIVILEGES;
      
      这时候,就可以连接了.
       
  • 不能连接 Docker 启动容器的 MySQL

  • 为了确保防火墙会对连接造成影响,我这里建议关闭防火墙
    
    命令1,关闭防火墙
    service firewalld stop
    
    命令2,查看防护墙的状态
    service firewalld status

     

     

  • 首先确保 MySQL 容器是运行正确的.
    
    命令1,查询所有的容器,我这里是没有容器存在的
    docker ps -a
    
    命令2,查询所有的镜像,我这里有 MySQL 的镜像 ,镜像名称为 mysql 标签为 latest
    docker images
    
    命令3,启动 MySQL 容器
    docker run -p 3307:3306 --name mysql01 -e MYSQL_ROOT_PASSWORD=123456 -d mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    
    命令3这句话表示什么:
    docker run   表示容器运行指令
    -p 3307:3306   表示自定义3307端口对应端口3306
    --name mysql01   表示设置容器名称为 mysql01  这里设置的名称不可以和 docker ps -a 指令查出的 NAMES 列名称相同,否则会报错
    -e MYSQL_ROOT_PASSWORD=123456   表示设置密码123456 少了此段话,容器启动也会报错
    -d   表示后台运行
    mysql   表示容器名称 因为我名称为mysql的镜像标签为 latest 所以不用设置标签,表示默认,也可以设置为 mysql:latest 如果标签不是 latest 就设置为mysql:标签ID
    --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci   表示设置编码
    
    命令4,再次查询所有的容器,此时可以看到容器正常运行,如果 STATUS 对应 Exited...... 就是运行错误
    docker ps -a

     

  •  

     

  • 如果Windows和虚拟机不能互ping,可以参考 https://www.cnblogs.com/taopanfeng/p/10978752.html

  •  

     

  •  

    从上往下依次进行
    
    命令1,登录 mysql 这里要把 192.168.1.110 换成你们自己的虚拟机 IP 地址,把3307端口号换成你们自己启动容器时设置的端口号
    执行完之后,输入密码
    mysql -h 192.168.1.110 -u root -p -P 3307
    
    命令2,使用mysql
    use mysql;
    
    命令3,查询
    select host,user,authentication_string from user ; 
    
    命令4,更新
    update user set authentication_string = 'root' where user = 'root' and host = '%';
    
    命令5,更新 把这里的 123456 换成你们设置的密码
    alter user 'root'@'%' identified with mysql_native_password by '123456';
    
    输入完命令5就可以连接数据库了
  •  

 

Guess you like

Origin www.cnblogs.com/taopanfeng/p/10986616.html