Hello, this is part two of the series!

If you have played with Rails before, you would know that the default database is SQLite. That is fine for development, for production having mySQL is better for handling more queries.

Deploying Rails to Centos 5

Make sure you have Apache installed before doing this. There are a few dependencies that you should install as well. Connect via ssh to your remote server and run this command [shell] yum install httpd-devel\
openssl-devel\
zlib-devel\
gcc\
gcc-c++\
curl-devel\
expat-devel\
gettext-devel\
mysql-server\
mysql-devel[/shell]

Once you are done, you can boot up mysql by doing this [shell] service mysqld start[/shell]

And also make sure that mySQL starts when you boot up your server. [shell]chkconfig mysqld on[/shell]

Now, let’s make sure that we have a database prepped for a test rails application. To do that, run [shell]/usr/bin/mysql -u root -p[/shell] Enter your root password if there is any.

You should be greeted with a friendly :[shell] mysql> [/shell]

If you want to change your root password you can do so by running this, [shell]UPDATE mysql.user SET Password = PASSWORD(‘password’) WHERE User = ‘root’;
FLUSH PRIVILEGES;[/shell]

Let’s create a database for our rails test application. 😀 [shell]CREATE DATABASE demodb;[/shell]
And add a user for this database. [shell] INSERT INTO mysql.user (User,Host,Password) VALUES(‘loginname’,’localhost’,PASSWORD(‘yourpassword’));
GRANT ALL PRIVILEGES ON demodb.* to loginname@localhost;
FLUSH PRIVILEGES;
[/shell]

Now you have a working database! Yay!

For a list of handy commands to communicate with your mySQL database, head here.

Next : Git