Docker操作数据库常见命令及问题解决
日期: 2020-04-20 分类: 跨站数据 286次阅读
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
精华推荐