linux怎么查看本机内存大小
308
2022-10-20
Docker安装Mysql 无法访问
问题如下:
在服务器用docker 安装启动mysql 容器 之后一直无法进入mysql
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
显示已经安装成功
[root@179-180 ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES18b734a8eb9c mysql "docker-entrypoint..." 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql-test
然后准备开始连接mysql 时,一直都是这样的:
[root@179-180 log]# mysql -h localhost -u root -p-bash: mysql: 未找到命令
或者是:
[root@179-180 lib]# cd mysql-bash: cd: mysql: 没有那个文件或目录
直到刚刚看了一张图片才发现,首先需要进入容器才能执行容器相关命令
docker exec -it mysql-test bash
[root@179-180 ~]# docker exec -it mysql-test bashroot@18b734a8eb9c:/# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 20Server version: 8.0.28 MySQL Community Server - GPLCopyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || openser || performance_schema || sys |+--------------------+5 rows in set (0.00 sec)...
对比进入容器前后 root 的标识
总结
多看多学
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~