I'm trying to get a rails app up and running on my computer, and I'm having issues with creating the databases. I've properly installed/setup rails, mysql and have installed the mysql 2.8.1 gem (I verified this with gem list).
So now, I'm trying to run 'rake db:create:all' and I'm getting the following error:
Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"pyo", "host"=>"localhost", "password"=>nil, "socket"=>"/tmp/mysql.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"pyo_test", "host"=>"localhost", "password"=>nil, "socket"=>"/tmp/mysql.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
I'm currently running 5.5.10 MySQL Community Server (GPL) on Snow Leopard (10.6.6)
And here is what is in my database.yml file
development:
adapter: mysql
encoding: utf8
database: pyo
username: root
password:
socket: /tmp/mysql.sock
host: localhost
test:
adapter: mysql
encoding: utf8
database: pyo_test
username: root
password:
socket: /tmp/mysql.sock
host: localhost
I notice how the end of the error says "charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)" -- Is that the issue? And if so, how do I fix it?
I've been stuck on this thing for hours and can't find anything that helps on Google. So any help at this point would be much appreciated.
Thanks!!
I know this thread is old but being a IT guy who believes in keeping good solid documentation in one place here goes:
The problem actually stems from your "config/database.yml" file. You are pointing ROR to the wrong location for the MySQL Socket.
I ran into this problem and what it turned out to be is the gem was built on a mac system and the developer did not account for other operating systems by putting his "mysql.sock" file in the "/tmp" directory rather than the "/var/run/mysqld/mysqld.sock" .
So his "database.yml" file looked like:
development:
adapter: mysql2
#encoding: utf8
database: somedatabase
pool: 5
username: someusername
password: somepassword
socket: /tmp/mysql.sock
Because I was on a Ubuntu System I had to change mine to the following:
development:
adapter: mysql2
#encoding: utf8
database: somedatabase
pool: 5
username: someusername
password: somepassword
socket: /var/run/mysqld/mysqld.sock
Yes the error can be misleading however it has nothing to do with your "encoding" or whether you are using localhost or 127.0.0.1 (At least in linux/UNIX systems these translate to the same thing and are synonymous)
Begin Edit
Also it is not good to have encoding commented out like I do above. So I am providing the modification here for reference.
development:
adapter: mysql2
encoding: utf8
database: somedatabase
pool: 5
username: someusername
password: somepassword
socket: /var/run/mysqld/mysqld.sock
End Edit
think I had something like this...fixed by adding this to database.yml:
host: 127.0.0.1
Or in your case, changing it from localhost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With