docker-compose中mysql修改身份验证方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[root@localhost zhi-docker]# docker ps<br><br>
CONTAINER ID   IMAGE                                       COMMAND                  CREATED       STATUS                 PORTS                                                                                                                         NAMES
abcf3396c4fc   free4inno/zhi-web:2.0.0                     "/bin/bash /usr/loca…"   3 hours ago   Up 3 hours             0.0.0.0:8081->8081/tcp, :::8081->8081/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp, 0.0.0.0:8888->80/tcp, :::8888->80/tcp   zhi-web
f5b9ee19dffa   free4inno/zhimysql:1.1                      "/entrypoint.sh --ch…"   3 hours ago   Up 3 hours (healthy)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                          zhimysql
61fbe4b00515   bolingcavalry/elasticsearch-with-ik:6.5.0   "/usr/local/bin/dock…"   3 hours ago   Up 3 hours             0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp                                          zhies-node-1
69a731c44ff7   bolingcavalry/elasticsearch-head:6          "grunt server"           3 hours ago   Up 3 hours             0.0.0.0:9100->9100/tcp, :::9100->9100/tcp                                                                                     zhies-head
[root@localhost zhi-docker]# docker run zhimysql
Unable to find image 'zhimysql:latest' locally
<br>
[root@localhost zhi-docker]# docker exec -it zhimysql bash
 
bash-4.2# mysql -uroot -p
Enter password:
 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 947
Server version: 8.0.18 MySQL Community Server - GPL
 
Copyright (c) 2000, 2019, 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.
 
 
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> select user,plugin from user where user='root';
+------+-----------------------+
| user | plugin                |
+------+-----------------------+
| root | caching_sha2_password |
+------+-----------------------+
1 row in set (0.00 sec)
 
mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | %         |
| healthchecker    | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)
 
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.01 sec)
 
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

  然后使用客户端连接数据库测试

posted @   今年我十八岁  阅读(114)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示