I’ve created a new application from scratch on a new development
machine. I’ve installed Ruby, Rails and MySQL using as many defaults as
possible.
I’m receiving the following error
Mysql::Error: query: not connected: INSERT INTO posts
when I try to add a new post to my database.
My database.yml development settings looks like
development:
database: blog_development
adapter: mysql
host: 127.0.0.1
username: root
password:
socket: /tmp/mysql.sock
What am I doing wrong?
Am 21.01.2010 um 11:35 schrieb Pale H.:
My database.yml development settings looks like
development:
database: blog_development
adapter: mysql
host: 127.0.0.1
username: root
password:
socket: /tmp/mysql.sock
What am I doing wrong?
Two things that come to mind:
- Did the migration creating the posts in the db run through correctly?
- Did you start your “rails server” (be it script/server, passenger or
whatever) in development mode?
Felix
Felix Schäfer wrote:
Am 21.01.2010 um 11:35 schrieb Pale H.:
My database.yml development settings looks like
development:
database: blog_development
adapter: mysql
host: 127.0.0.1
username: root
password:
socket: /tmp/mysql.sock
What am I doing wrong?
Two things that come to mind:
- Did the migration creating the posts in the db run through correctly?
- Did you start your “rails server” (be it script/server, passenger or
whatever) in development mode?
Felix
In response to 1. The migration ran fine. I thought I’d repaired a
similar error when I previously tried to run the migration by changing
the client library in /bin. Could this be the problem?
In response to 2. I initiated the server with ruby script/server
command. I would presume it’s running in development mode as the
application is reloaded on page refresh.
Any thoughts?
Hello Pale,
You need to install gem for mysql.
gem install mysql
also if you are running your app at local machine then use ‘localhost’
as
host.
try to make make your development config like
development:
adapter: mysql
encoding: utf8
reconnect: false
database: test_development
pool: 5
username: root
password: root
host: localhost
Thanks & Regards
Ankit Varshney
Ankit Varshney wrote:
Hello Pale,
You need to install gem for mysql.
gem install mysql
also if you are running your app at local machine then use ‘localhost’
as
host.
try to make make your development config like
development:
adapter: mysql
encoding: utf8
reconnect: false
database: test_development
pool: 5
username: root
password: root
host: localhost
Thanks & Regards
Ankit Varshney
Thank you for your response.
I’ve already installed the MySQL gem so that’s not the issue. localhost
or the address I specified are both fine to use as the host. I even went
as far back as to ensure a database existed (despite my migration
running without a problem).
To solve the issue, I replaced the client library and restarted my
server.