We have installed Ruby and Rails before, and can install more required packages through gem.
Next, we need to install the database again.
By default, RoR uses Sqlite as the data storage engine. Although Sqlite is sufficient in small applications, it is compatible with MySQL and easy to migrate. However, considering that most of the actual product environments still use a comprehensive database system such as MySQL and Oracle, it is better to install a MySQL on the local machine.
Install MySQL
First download the MySQL for Windows version from dev.mysql.com, and then install it.
If necessary, you can also download MySQL Workbench (recommended) to design the database, or download MySQL GUI Tools to manage your database server in a graphical manner.
Install MySQL gem
After installing MySQL, if your Ruby does not support the mysql Driver (Integrated Instant Rails already exists), you need to install the MySQL driver in Ruby.
gem
install
mysql
This will install the mysql-2.7.3-mswin32.gem on. It should be noted that this driver supports Ruby 1.8, and currently there is no 1.9 compatible gem on Windows (mswin32) (mysql-ruby-2.8x already supports 1.9, however, if the compiled gem does not appear, you need to compile it by yourself-and the entire compilation will be very painful ).
Mysql-2.8.1-mswin32.gem was released on, which supports Ruby 1.9.
Test MySQL operations in Ruby
First, you must ensure that your MySQL has been successfully installed on the local machine and can be connected (use the local MySQL test here, the root password is blank, you can adjust the parameters according to your specific environment ):
Connect to MySQL:
C: \ Users \ wxy> mysql-uroot mysqlWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 5 Server version: 5.1.37-community MySQL Community Server (GPL) Type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> show tables; + ------------------------- + | Tables_in_mysql | + ----------------------------- + | columns_priv | db | event | func | general_log | (omitted) | user | + ------------------------- + 23 rows in set (0.01 sec) mysql> quitByeC: \ Users \ wxy>
Then you can test whether the Mysql module is successfully installed through irb:
C: \ Users \ wxy> irbirb (main): 001: 0> require 'mysql' => trueirb (main): 003: 0> dbh = mysql. real_connect ("localhost", "root", "", "mysql") =># <Mysql: 0x263e9a0> irb (main): 004: 0> res = dbh. query ("show tables") =># <Mysql: Result: 0x25ba320> irb (main): 005: 0> res. each do | row | irb (main): 006: 1 * puts row [0] irb (main): 007: 1> endcolumns_privdbeventfuncgeneral_log (Omitted) user =># <Mysql :: result: 0x25ba320> irb (main): 009: 0> res. free => nilirb (main): 010: 0> dbh. close ==#< Mysql: 0x263e9a0>
The preceding instructions can be used to connect to and query MySQL through Ruby.
From: http://rordiary.com/blog/