Just trying to get my first database based rails app up on dreamhost.com. The app was working prior to putting in mysql DB usage
but I’m just stuck on getting the app working with mysql. I’ve already
created the database and can connect to it manually.
Below is the error I get after running the rake migrate. It worked OK
on my home PC environment. I did change the enviroment to “test” on the dreamhost.com site.
It seems I can’t get ftp or ssh access to dream host from work at the
moment, however I don’t remember seeing a “port” entry in my config
file. If I had omitted this would this explain the error?
(I just adjusted the out of the box rails settings, and I used the
“TEST” environment, as I still want to be dynamic for testing changes
but did not want to use DEVELOPMENT so I could still test on my local PC
at home without having to change things. So if the PORT line isn’t in
the standard TEST entry in database.yml out of the box from rails then I
wouldn’t have had it in at dreamhost)
Dan K. wrote:
Tom, I think your database.yml is misconfigured. It should not use
It should look exactly like this, which connects to MySQL over a TCP
connection:
Dan - I’ve been looking for the syntax/documentation for database.yml so
I can firm up my understanding of what you’re suggesting. Can you give
any pointers off hand for where I should look for this?
tks
greg
Dan K. wrote:
I suspect your problem has to do with the test database being
special. It’s designed to be replicated from the development
database schemas and populated with fixtures when you run tests. Try
creating a forth entry in your database.yml called server-devel and
see if you can get that set up correctly.
I suspect your problem has to do with the test database being
special. It’s designed to be replicated from the development
database schemas and populated with fixtures when you run tests. Try
creating a forth entry in your database.yml called server-devel and
see if you can get that set up correctly.
Actually I’ve just found some info in the Rails API guide (see below).
I’m guessing what is required is the “:socket” option entry to be setup
as follows:
socket: /var/run/mysqld/mysqld.sock
Or actually I’m not sure if this (from the error log) is the incorrect
location that my app was trying, or whether it was the correct one?
If it were the incorrect location then I guess I need to find out where
Dreamhost has the mysqld.sock file located?
Will try this once I get home.
==============
The MySQL adapter will work with both Ruby/MySQL, which is a Ruby-based
MySQL adapter that comes bundled with Active Record, and with the faster
C-based MySQL/Ruby adapter (available both as a gem and from MySQL/Ruby).
Options:
* :host â?? Defaults to localhost
* :port â?? Defaults to 3306
* :socket â?? Defaults to /tmp/mysql.sock
* :username â?? Defaults to root
* :password â?? Defaults to nothing
* :database â?? The name of the database. No default, must be
provided.
* :sslkey â?? Necessary to use MySQL with an SSL connection
* :sslcert â?? Necessary to use MySQL with an SSL connection
* :sslcapath â?? Necessary to use MySQL with an SSL connection
* :sslcipher â?? Necessary to use MySQL with an SSL connection
If you’re still having problems, you might consider editing the
database.yml from a fresh rails install (rails temp), as things like
spurious tabs can be hard to debug.
I think dreamhost have their mysql database on a different server, hence
their request to put the mysql.youdomain.name in.
I’m still stuck on this for the moment - no response from Dreamhost yet.
Henning K. wrote:
Greg H. wrote:
Actually I’ve just found some info in the Rails API guide (see below).
I’m guessing what is required is the “:socket” option entry to be setup
as follows:
socket: /var/run/mysqld/mysqld.sock
That would be the default socket, which I’m guessing dreamhost isn’t
using. the best option here is probably to go TCP - the socket means
you’re using a “pipe” connection to mysql, i.e. not invoking the TCP
stack.
Just comment out or delete the socket line completely, and setup mysql
host: localhost, port: 3306.
Actually I’ve just found some info in the Rails API guide (see below).
I’m guessing what is required is the “:socket” option entry to be setup
as follows:
socket: /var/run/mysqld/mysqld.sock
That would be the default socket, which I’m guessing dreamhost isn’t
using. the best option here is probably to go TCP - the socket means
you’re using a “pipe” connection to mysql, i.e. not invoking the TCP
stack.
Just comment out or delete the socket line completely, and setup mysql
host: localhost, port: 3306.
This is a working dreamhost config. Have you configured your MySQL
correctly on Dreamhost (picking a unique domain name for it, etc.)
Can you connect to it using MYSQLFront on Windows or CocoaMySQL on a
Mac?
BTW - Whilst the dreamhost wiki
(http://wiki.dreamhost.com/index.php/Ruby_on_Rails) suggests there is no
need for a :socket entry in database.yml I am still getting the "Can’t
connect to local MySQL server through socket
‘/var/run/mysqld/mysqld.sock’ " error when using “rake db:migrate”.
I did check the mysql socket location on dreamhost but I couldn’t see
this directory? Perhaps unix permissions or a real issue? See below:
Any ideas anyone?
[skybar]$ mysql_config --socket
/var/run/mysqld/mysqld.sock
[skybar]$
[skybar]$
[skybar]$ cd /var/run/mysqld
-bash: cd: /var/run/mysqld: No such file or directory
Regards
Greg
PS If anyone has a working dreamhost Ruby on Rails application I’d love
to see an example of your database.yml file.
Tks Dan - One final question of clarification (hopefully)
The “host: yourdb.yourhostname.com” - what would this look like exactly
for a dreamhost site, say where the app is hosted under a subdomain like subdomain1.mysite.com? Is it supposed to start with “mysql.”?
Dan K. wrote:
This is a working dreamhost config. Have you configured your MySQL
correctly on Dreamhost (picking a unique domain name for it, etc.)
Can you connect to it using MYSQLFront on Windows or CocoaMySQL on a
Mac?
Yes. I’ve set up the database on dreamhost OK, I’m able to connect to
it via “mysql -u dbuser -p -h mysql.gregnet.org databasename”. Also I’m
able to run the app successfully via the “ruby script/server” startup &
then connect to it via port 3000.
I’ll retry again when I’m home using your syntax for the database.yml,
however would you be able to give me an example of your “host” line in
your database.yml? Do you actually use the “mysql” at the start
like “mysql.gregnet.org”?
BTW - Did my previous post re the fact I couldn’t see the winsock file
on dreamhost make sense to you?
ie.
[skybar]$ mysql_config --socket
/var/run/mysqld/mysqld.sock
[skybar]$
[skybar]$
[skybar]$ cd /var/run/mysqld
-bash: cd: /var/run/mysqld: No such file or directory
As I understand it, there are two ways to talk to MySQL. Via TCP or
via socket. Since it’s on another machine, I believe TCP is your
only option. My host line looks like:
But that’s just because I chose to call it exampledb. If you’re able
to run script/server (I would generally use script/console to test my
database connections), I don’t quite understand the problem. Why are
you trying to use mysql_config? Also, note that for both scripts you
need to specify production to get them to connect to the right database.
I’ll try this syntax when I get home, thanks. I’ll also try the
script/console tip too.
Re “Why are you trying to use mysql_config” - I just used this as I
found advice that suggested “mysql_config --socket” was the way to find
out for your ISP where the mysql.sock file is located.
BTW - Just to reconfirm the “can’t connect to local MySQL server through
socket” error is hitting me as I’m trying to run “rake db:migrate” to
get the tables created in the production database. So I guess I’m
assuming that running this rake command is the acceptable method of
configuring one’s production database.
Greg, there’s no preconfigured server; you set it up. In panel.dreamhost.com, select Goodies, Manage MySQL, and your server
will show with its hostname, database name, etc. You might also
consider creating a new database.
Hey Dan - guess what. The problem was simply that I was using:
rake db:migrate
and not
rake db:migrate RAILS_ENV=“production”
I’d assumed without question that the rake command would be aware of the
PRODUCTION setting I had put in place, but I guess it obviously isn’t
aware of this setting
I wonder how I could have picked this up earlier.
Anyway, thats for the help, I’ve learnt lots on the way
Greg
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.