简体   繁体   中英

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. 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. Side note I am using Windows 10.

After running the command (rake db:create) I get this error.
#<Mysql2::Error: Can't connect to MySQL server on 'localhost' (10061)>

Here is my database.yml file

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:

/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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM