Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating Rails DB using rake db:create

I'm attempting to get my first "hello world" rails example going using the rails' getting started guide on my OSX 10.6.3 box.

When I go to execute the first rake db:create command (I'm using mysql) I get:

simon@/Users/simon/source/rails/blog/config: rake db:create  (in /Users/simon/source/rails/blog) Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"blog_development", "pool"=>5, "password"=>nil, "socket"=>"/opt/local/var/run/mysql5/mysqld.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

I found plenty of stackoverflow questions addressing this problem with the following advice:

  1. Verify that user and password are correct (I'm running w/ no password for root on my dev box)

  2. Verify that the socket is correct - I can cat the socket, so I assume it's correct

  3. Verify that the user can create a DB (As you can see root can connect and create a this DB no problem)

    simon@/Users/simon/source/rails/blog/config: mysql -uroot -hlocalhost Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 Server version: 5.1.45 Source distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> create database blog_development; Query OK, 1 row affected (0.00 sec)

to ensure that this wasn't a charset issue I also tried:

mysql> create database foobar CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

Note: here is my database.yaml:

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: blog_development
  pool: 5
  username: root
  password:
  socket: /opt/local/var/run/mysql5/mysqld.sock
#  host: localhost

Note that I tried switching socket to localhost with no effect.

Any idea on what might be going on here?

like image 651
Simon Avatar asked May 11 '26 05:05

Simon


1 Answers

Thanks for all the help guys. Looks like the problem had to do with my install of the mysql gem under OSX.

@tim after I proceeded to the next step and got up and going I got an error on the console, so I did a bit of searching and found this helpful thread.

After I uninstalled my ruby gems gem uninstall mysql I installed the proper mysql gems using this command (from the thread):

export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config

After executing this one I was able to successfully run rake db:create and proceed.

Thanks!!

like image 184
Simon Avatar answered May 12 '26 20:05

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!