简体   繁体   English

在新的EC2实例中启动mysql会引发“无法通过套接字连接”错误

[英]Starting mysql in new EC2 instance throws “can't connect through socket” error

I have an ec2 instance, but when i run mysql, it gives me this error 我有一个ec2实例,但是当我运行mysql时,它给了我这个错误

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

Similarly, when i run 同样,当我跑步时

/etc/init.d/mysql start

Oct 31 11:29:16 domU-12-31-38-00-A8-62 /etc/init.d/mysql[5263]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

What is wrong? 怎么了?

I had this same problem on an ec2 instance. 我在ec2实例上遇到了同样的问题。 These instructions worked perfectly for me: 这些说明非常适合我:


Redhat Enterprise Linux - RHEL 5 / 6 MySQL installation Redhat Enterprise Linux-RHEL 5/6 MySQL安装

Type the following command as root user: 以root用户身份键入以下命令:

yum install mysql-server mysql

Redhat Enterprise Linux - RHEL 4/3 MySQL installation Redhat Enterprise Linux-RHEL 4/3 MySQL安装

Type the following command as root user: 以root用户身份键入以下命令:

up2date mysql-server mysql

Start MySQL Service 启动MySQL服务

To start the mysql server type the following command: 要启动mysql服务器,输入以下命令:

chkconfig mysqld on
/etc/init.d/mysqld start

Setup the mysql root password 设置mysql root密码

Type the following command to setup a password for root user: 键入以下命令为root用户设置密码:

mysqladmin -u root password NEWPASSWORD

Test the mysql connectivity 测试mysql连接

Type the following command to connect to MySQL server: 键入以下命令以连接到MySQL服务器:

$ mysql -u root -p

Well, maybe the server is not running? 好吧,也许服务器未运行? :) :)

At the bare minimum: 至少:

ps aux|grep [m]ysql

If this returns nothing, then MySQL is not running. 如果没有返回任何内容,则说明MySQL未运行。

Troubleshoot by adding the following to the config file: log_error=/path/to/logfile 通过将以下内容添加到配置文件来进行故障排除: log_error=/path/to/logfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mysql无法通过Amazon EC2上的套接字连接到本地服务器 - Mysql can't connect to local server through socket on Amazon EC2 只是无法远程连接到MySQL EC2 ubuntu实例 - Just can't connect to MySQL EC2 ubuntu instance remotely 如何在ec2 bitnami上修复(2002,“无法通过socket连接到本地MySQL服务器'/tmp/mysql.sock'(2)”)? - how to fix (2002, “Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)”) on ec2 bitnami? 无法连接到在EC2实例(非RDS)上运行的远程MySQL实例 - Can't Connect to MySQL instance Remotely that is running on EC2 Instance (Not RDS) 无法从 EC2 实例连接到 RDS 实例 - Can't connect to RDS instance from EC2 instance 无法从Amazon EC2实例连接到外部主机上的mysql服务器 - Can't connect from an amazon ec2 instance to a mysql server on an external host 无法从 Amazon linux EC2 实例上的 Wordpress 连接到 RDS mysql 数据库 - Can't Connect to RDS mysql DB from Wordpress on Amazon linux EC2 Instance Oozie不在AWS EC2实例中以Mysql开头 - Oozie not starting with Mysql in AWS EC2 instance 为什么我不能直接连接到MySQL RDS数据库实例? (我只能通过SSH连接到EC2) - Why can't I connect directly to my MySQL RDS DB Instance? (I can only connect via SSHing into an EC2) MySQL - Mac - 错误2002 - 无法连接到本地...通过套接字 - MySQL - Mac - Error 2002 - Can't connect to local… through socket
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM