Error creating Rails DB with rake db: create

I am trying to use my first "hello world" example using a rails getting started guide on my OSX 10.6. 3.

When I go to execute the first command rake db:create(I use 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 many stackoverflow questions addressing this issue with the following tips:

  • Make sure the user and password are correct (I run w / no password for root in my dev block)

  • Make sure the socket is correct - I can cat the socket, so I assume it is correct

  • Make sure that the user can create the database (since you can see that root can connect and create this database without any problems)

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

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

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

to make sure this is not an encoding issue that 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

Please note that I tried switching the socket to localhost without effect.

Any idea what could happen here?

+3
source share
6 answers

. , gem mysql OSX.

@tim , , , .

gem uninstall mysql, mysql, ( ):

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

rake db:create .

!!

+5

.

  • ​​ utf8?
  • , .
  • gem mysql? sudo gem install mysql
  • , MySQL, 5.0

, .

+2

database.yml

, UTF-8, , utf-8

create database foobar CHARACTER SET utf8 COLLATE utf8_general_ci
+1

blog_development?

, .

ruby script/server blog/.

, localhost:3000 http://guides.rubyonrails.org/getting_started.html#hello-rails.

, ruby script/server .

0

: mysql gem, . mysql .

0

mysql- mysql-, :

sudo apt-get install mysql-server mysql-client

, , MySQL ruby:

sudo apt-get install libmysql-ruby

. !!!:)

0

Source: https://habr.com/ru/post/1741886/


All Articles