linux中mysql客户端命令行连接不了 docker 创建的mysql
linux中mysql客户端命令行连接不了 docker 创建的mysql问题 :如题a@z:~$ mysql -h localhost -pERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)a@z:~$ mysql -h 127.0.0.1
·
linux中mysql客户端命令行连接不了 docker 创建的mysql
问题 :如题
a@z:~$ mysql -h localhost -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
a@z:~$ mysql -h 127.0.0.1 -p
ERROR 1045 (28000): Access denied for user 'xiao'@'172.18.0.1' (using password: YES)
a@z:~$ mysql -h 127.0.0.1 -p
解决方案
连接ip地址的时候,写 mysql 容器的ip
a@z:~$ mysql -u root -p -h 172.18.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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.
更多推荐
已为社区贡献21条内容
所有评论(0)