Young87

SmartCat's Blog

So happy to code my life!

游戏开发交流QQ群号60398951

当前位置:首页 >跨站数据

Docker操作数据库常见命令及问题解决

1.列出本地主机上的镜像。

docker images

 

2.下载mysql镜像

docker pull centos/mysql‐57‐centos7

 

3.创建mysql容器

docker run ‐di ‐‐name=jane_base ‐p 3306:3306 ‐e  MYSQL_ROOT_PASSWORD=123456  centos/mysql‐57‐centos7

docker run -p 3306:3306 --name=jane_base -e MYSQL_ROOT_PASSWORD=123456 -d mysql

4.查询mysql端口号

docker port 数据库名

 

5.进入mysql

docker exec -it(jane_base) bash

 

6.输入账号,密码

mysql -u root -p

 

本地连接数据库错误:

ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'

 

mysql连数据库的时候报错:

1251 client does not support authentication protocol requested by server;consider upgrading Mysql client

ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'

先登录mysql

mysql -u root -p

输入密码

mysql> use mysql; mysql> select user,host from user;

+------------------+-----------+

| user             | host      |

+------------------+-----------+

| root             | %         |

| admin            | localhost |

| mysql.infoschema | localhost |

| mysql.session    | localhost |

| mysql.sys        | localhost |

| zhangj           | localhost |

+------------------+-----------+

注意我的root,host是'%'

你可能执行的是:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';

改成:

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

 

除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog

上一篇: [小白向]Linux(Deepin)安装Maven并配置本地仓库、阿里云镜像、设置默认jdk

下一篇: 【华为云技术分享】气象模拟WRF容器化操作实践

精华推荐