Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake db:create generated "if you set the charset manually, make sure you have a matching collation" error

I got a rails project in version 2.3.8. When i tried to run rake db:create, the below error occured.

Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"claims_test", "host"=>"localhost", "password"=>"root", "socket"=>"/var/run/mysqld/mysqld.sock"}, charset: utf8, collation: utf8_unicode_ci   
(if you set the charset manually, make sure you have a matching collation)

And I created DB manually and tried to run the application. And now I am getting this error.

/!\ FAILSAFE /!\  Tue May 10 20:38:48 +0530 2011  
  Status: 500 Internal Server Error  
  uninitialized constant MysqlCompat::MysqlRes  

I tried with both Webrick and mongrel and it seems like same cause for both issue.

like image 217
shajin Avatar asked May 10 '11 15:05

shajin


2 Answers

Ah, this error is so common. Its MySQL. Here is the solution. Change paths as required. Let us know how you get on. All the best.

export ARCHFLAGS="-arch i386 -arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local \ --with-mysql-config=/usr/local/bin/mysql_config
like image 103
ChuckJHardy Avatar answered Oct 23 '22 01:10

ChuckJHardy


I ran into the same error. In my case, the problem was that I hadn't created the MySQL user who was specified in database.yml.

mysql --user=root mysql
grant all privileges on *.* to 'user_name_here'@'localhost' identified by 'password_here';
exit;
like image 32
Alex D Avatar answered Oct 23 '22 01:10

Alex D