docker下mysql8版本的安装运行及navicat的连接

编程

$ mkdier -p /etc/docker

$ tee /etc/docker/daemon.json << "EOF"

{

"registry-mirrors":["https://9cpn8tt6.mirror.aliyuncs.com"]

}

EOF

$ systemctl daemon-reload

$ systemctl restart docker

速度那是杠杠的!!

二、启动

1.增加数据文件夹

$ mkdir -p /opt/docker-mysql/var/lib/mysql

2.启动,设置默认密码 abc123

$ docker -run --name mysql 

--restart=always

-p 3306:3306

-v /opt/docker-mysql/var/lib/mysql:/var/lib/mysql

-e MYSQL_ROOT_PASSWORD=abc123

-d mysql:8.0.19

三、设置远程工具navicat连接

由于mysql8更改的加密方式,连接会报1251错误。方法是更改mysql密码验证方式:

1.进入docker 的mysql

$ docker exec -it mysql /bin/bash

2.进入mysql

mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 17

Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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.

3.更改用户的连接和验证方式

alter user "root"@"localhost" identified with mysql_native_password by "abc123"

或者是远程连接:

alter user "root"@"%" identified with mysql_native_password by "abc123"

4.连接

5.OK啦

以上是 docker下mysql8版本的安装运行及navicat的连接 的全部内容, 来源链接: utcz.com/z/515340.html

回到顶部