I am able to access mysql via workbench with hostname: localhost and port: 3306 which were present by default, but I can't connect it via bash
mysql -u root -p
returns follwing error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
How to connect mysql in docker via bash?
You need to use the -h
arugument:
mysql -h 127.0.0.1 -u root -p
The error message tells you that mysql
tried to connect to the unix socket /var/run/mysqld/mysqld.sock
and not to the network socket.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.