Create new Rails with mysql default on database.yml

Hello, I’m trying to connect with a db in my app, but when I go on
config/database.yml the default db is sqlite3, how can I put the mysql
as default ?

SQLite version 3.x

gem install sqlite3

Ensure the SQLite 3 gem is defined in your Gemfile

gem ‘sqlite3’

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

Warning: The database defined as “test” will be erased and

re-generated from your development database when you run “rake”.

Do not set this db to the same as development or production.

test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Thanks

On Sun, Jan 22, 2012 at 2:17 PM, Felipe Pieretti U.
[email protected] wrote:

Hello, I’m trying to connect with a db in my app, but when I go on
config/database.yml the default db is sqlite3, how can I put the mysql
as default ?

rails new --help


Hassan S. ------------------------ [email protected]

twitter: @hassan

felipe@Felipe:~/rails_projects$ rails new --help
Usage:
rails new APP_PATH [options]

Options:
-r, [–ruby=PATH] # Path to the Ruby binary of your
choice
# Default:
/home/felipe/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
-b, [–builder=BUILDER] # Path to a application builder (can be
a filesystem path or URL)
-m, [–template=TEMPLATE] # Path to an application template (can
be a filesystem path or URL)
[–skip-gemfile] # Don’t create a Gemfile
[–skip-bundle] # Don’t run bundle install
-G, [–skip-git] # Skip Git ignores and keeps
-O, [–skip-active-record] # Skip Active Record files
-S, [–skip-sprockets] # Skip Sprockets files
-d, [–database=DATABASE] # Preconfigure for selected database
(options:
mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [–javascript=JAVASCRIPT] # Preconfigure for selected JavaScript
library
# Default: jquery
-J, [–skip-javascript] # Skip JavaScript files
[–dev] # Setup the application with Gemfile
pointing to your Rails checkout
[–edge] # Setup the application with Gemfile
pointing to Rails repository
-T, [–skip-test-unit] # Skip Test::Unit files
[–old-style-hash] # Force using old style hash (:foo =>
‘bar’) on Ruby >= 1.9

Runtime options:
-f, [–force] # Overwrite files that already exist
-p, [–pretend] # Run but do not make any changes
-q, [–quiet] # Supress status output
-s, [–skip] # Skip files that already exist

Rails options:
-h, [–help] # Show this help message and quit
-v, [–version] # Show Rails version number and quit

Description:
The ‘rails new’ command creates a new Rails application with a
default
directory structure and configuration at the path you specify.

You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home 

directory.

Note that the arguments specified in the .railsrc file don't affect 

the
defaults values shown above in this help message.

Example:
rails new ~/Code/Ruby/weblog

This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.

felipe@Felipe:~/rails_projects$

Ok, but how I can make the mysql be default ?

On Sun, Jan 22, 2012 at 2:41 PM, Felipe Pieretti U.
[email protected] wrote:

felipe@Felipe:~/rails_projects$ rails new --help

No need to post the results – they’re the same for everybody :slight_smile:


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Sun, Jan 22, 2012 at 5:16 PM, Felipe Pieretti U.
[email protected] wrote:

Ok, but how I can make the mysql be default ?

Uh, well – the reason I suggested running that command is that the
answer is in the output. :slight_smile:


Hassan S. ------------------------ [email protected]

twitter: @hassan

On 01/22/2012 06:16 PM, Felipe Pieretti U. wrote:

Ok, but how I can make the mysql be default ?

To make mysql the default when you run rails new you would have to
modify the rails code somewhere (If you cannot figure out where on your
own you should not try to modify it). To change the database driver
used on this particular instance modify config/database.yml. Run rails
new xx -d mysql to see what the values in that file should be.

On Mon, Jan 23, 2012 at 5:06 AM, Noel [email protected] wrote:

In 3.2 you can define .railsrc with custom command line options that will
always apply to rails new

Wow, that’s great :slight_smile:

$ cat ~/.railsrc
–skip-bundle
-T
-d postgresql

$ time rails new test_3_2
Using --skip-bundle -T -d postgresql from /home/peterv/.railsrc
create

real 0m0.134s
user 0m0.108s
sys 0m0.024s

My special thanks to "7039def6 (Guillermo Iguaran " for this :slight_smile:

Peter

Ok, I create a new project with rails new new_project -d mysql, but it
create as default database mysql2… is correct ?

MySQL. Versions 4.1 and 5.0 are recommended.

Install the MYSQL driver

gem install mysql2

Ensure the MySQL gem is defined in your Gemfile

gem ‘mysql2’

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock

Warning: The database defined as “test” will be erased and

re-generated from your development database when you run “rake”.

Do not set this db to the same as development or production.

test:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_test
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_production
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock

Yep. You need to use mysql2 gem in a rails 3 project to avoid encoding
problems!

thx

2012/1/23 Felipe Pieretti U. [email protected]

socket: /var/run/mysqld/mysqld.sock
username: root
password:
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


thiagocifani

twitter.com/thiagocifani
del.icio.us/thiagocifani
http://del.icio.us/thiagocifani

In 3.2 you can define .railsrc with custom command line options that
will always apply to rails new

Sent from my iPhone