在Docker中安装MySQL失败,并显示错误消息“无法通过套接字连接到本地MySQL服务器". [英] Installing MySQL in Docker fails with error message "Can't connect to local MySQL server through socket"

查看:600
本文介绍了在Docker中安装MySQL失败,并显示错误消息“无法通过套接字连接到本地MySQL服务器".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在docker容器中安装mysql,尝试了来自github的各种图像,似乎它们都设法成功安装了mysql,但是当我尝试运行mysql时却出现了错误:

I'm trying to install mysql inside a docker container,Tried various images from github, it seems they all manage to successfully install the mysql but when I try to run the mysql it gives an error:

错误2002(HY000):无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

系统规格:

  • Ubuntu 12,04在AWS上
  • Docker 0.10.0

到目前为止我尝试过的包裹:

Packages I tried so far:

  • https://github.com/eugeneware/docker-wordpress-nginx
  • https://github.com/tutumcloud/tutum-docker-mysql

推荐答案

请记住,您将需要连接到正在运行的docker容器.因此,您可能要使用tcp而不是unix套接字.检查docker ps命令的输出,并查找正在运行的mysql容器.如果找到一个,则使用mysql命令,如下所示:mysql -h 127.0.0.1 -P <mysql_port>(您将在docker ps输出中找到端口). 如果在docker ps输出中找不到任何正在运行的mysql容器,请尝试docker images查找mysql映像名称,然后尝试执行以下操作: docker run -d -p 3306:3306 tutum/mysql其中"tutum/mysql"是在docker images中找到的映像名称.

Remember that you will need to connect to running docker container. So you probably want to use tcp instead of unix socket. Check output of docker ps command and look for running mysql containers. If you find one then use mysql command like this: mysql -h 127.0.0.1 -P <mysql_port> (you will find port in docker ps output). If you can't find any running mysql container in docker ps output then try docker images to find mysql image name and try something like this to run it: docker run -d -p 3306:3306 tutum/mysql where "tutum/mysql" is image name found in docker images.

这篇关于在Docker中安装MySQL失败,并显示错误消息“无法通过套接字连接到本地MySQL服务器".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆