[英]Ruby on Rails - Mysql2::Error: Can't connect to MySQL server on 'localhost' (10061)
Hey I'm just getting started with Ruby on Rails and need some help. 嘿,我刚开始使用Ruby on Rails,需要一些帮助。 I installed Ruby on Rails and then created a project with MySQL but I am unable to connect to the MySQL server to create a database.
我安装了Ruby on Rails,然后使用MySQL创建了一个项目,但是无法连接到MySQL服务器来创建数据库。 Side note I am using Windows 10.
旁注我正在使用Windows 10。
After running the command (rake db:create) I get this error. 运行命令(rake db:create)后,出现此错误。
#<Mysql2::Error: Can't connect to MySQL server on 'localhost' (10061)>
Here is my database.yml file 这是我的database.yml文件
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: 1234
host: localhost
Assuming you're running Linux, try the following command to see if MySQL is running: 假设您正在运行Linux,请尝试以下命令以查看MySQL是否正在运行:
/etc/init.d/mysql status
Make sure you're specifying a database
name to connect to as well, but that would likely give you a different error code than the one you're seeing. 确保同时指定了要连接的
database
名称,但这可能会给您与您看到的错误代码不同的错误代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.