Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAh Ren
175 Pointscan't connect to local MySQL server through socket '/tmp/mysql.sock'
failed to run command rake db:create.
Error message:
<Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)>
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"MyStore_App_development"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"} (If you set the charset manually, make sure you have a matching collation)
<Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)>
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"MyStore_App_test"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"} (If you set the charset manually, make sure you have a matching collation)
Asma Al-Marrikhi
45,525 PointsAnd for mysql -uroot
mysql -uroot -p
it will ask for password ( the password is the same for your (root'@'localhost ) and same what you write it in (database.yml ) file ..) It is work with me 100% ..
2 Answers
Nelly Nelly
7,134 PointsHello !
I still have this, what am I doing wrong??
$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I've followed your suggestion
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: password1
host: localhost
development:
<<: *default
database: biller_development
Asma Al-Marrikhi
45,525 Pointsthe password should be the same in both (MySQLWorkbench) and database.yml
Nelly Nelly
7,134 PointsOh thanks ! I am just starting the database fundation tutorial I had skipped it ! It would help then :) I am having trouble with the workbench though :(
Asma Al-Marrikhi
45,525 PointsAsma Al-Marrikhi
45,525 Points1- open biller folder on (sublime text ) . 2- then go to (database.yml ) file on config folder 3- write your password for (root'@'localhost ) that you use it on (MySQLWorkbench) program : 4- save (database.yml ) file
on (database.yml ) file