ducker mysql连接不上_docker mysql无法远程连接问题:

docker exec -it 容器Id bash

mysql -u root -p

输入密码报错:

Access denied for user 'mysql'@'localhost' (using password: YES)

退出容器,找到挂载的配置文件目录,在

[mysqld]

user=mysql

character-set-server=utf8

pid-file        = /var/run/mysqld/mysqld.pid

socket          = /var/run/mysqld/mysqld.sock

datadir         = /var/lib/mysql

#log             = /var/log/mysqld_common.log

log-error       = /var/log/mysqld_err.log

log-bin         = /var/log/mysqld_bin.bin

secure-file-priv= /var/lib/mysql

expire_logs_days=7

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

max_connections=1000

#skip-grant-tables

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

#--skip-host-cache

#--skip-name-resolve

[mysqld] 下任意行加入skip-grant-tables

重起容器

docker restart 容器Id

进入容器,连接mysql;

use mysql

更新root密码

select user,authentication_string from user;

update user set authentication_string=''  where user='root';

注释掉my.cnf 文件中的 skip-grant-tables

再次重起容器,进入容器,连接mysql

alter user'root'@'%' IDENTIFIED BY '123456';

#alter user'root'@'localhost' IDENTIFIED BY '123456';

flush privileges;

发现用mysql客户端navcat连接,报 连不上

MYSQL 8.0内新增加mysql_native_password函数,通过更改这个函数密码来进行远程连接。更改ROOT用户的native_password密码

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY'Mysql@123';

执行完成。既可以连接了。

查看变量值:

SHOW VARIABLES LIKE 'lower%';

参考地址:https://blog.csdn.net/zhldt2008/article/details/81127145

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值