1. Install wamp1.7.4 to automatically install Apache and Mysql,apache ports may be occupied by IIS services, you can go to the control panel to shut down
2. Change the root password, in order to continue to operate the database in the phpMyAdmin, need to Wamp installation path in the phpMyAdmin to find config.inc.php, file search "password", the original
Blank password modified to "root", restart Wamp, you can access the phpMyAdmin
3. Copy the Libmysql.dll from the bin directory in the MySQL installation directory to the bin directory of the Ruby installation directory (my c: \ruby\bin , which is modified with your own Ruby installation path)
4. To https://rubygems.org/gems/rdoc/versions download Rdoc-2.4.3.gem then copy the Rdoc-2.4.3.gem to the D:ror directory (the directory is built by me, the reader is free), then the command line:
CD D:\ror
Gem Install Rdoc-2.4.3.gem
The move is for a smooth installation of MySQL for Ruby documentation later
5. To https://rubygems.org/gems/rdoc/versions search download Download mysql gem driver file, I downloaded the Mysql-2.8.1.gem, copied to the D:ror directory (the directory is built by me, the reader can freely )
Install MySQL for Ruby driver, command line type: Gem install Mysql-2.8.1.gem
6. Go to http://download.csdn.net/detail/luoyeyilin/3614807 download Instantrails-2.0-win.zip extract, search under mysql.so,80k size file Copy the mysql.so to the C:\RUBY\LIB\RUBY\SITE_RUBY\1.8\I386-MSVCRT.
You can then connect in the code (the limited need to create a new person table in database test with navicate for MySQL, create two column IDs and Name,,id set as the primary key, and then assign several initial values):
And then you can write the program to connect
1 #ENCODING:GBK2Require'MySQL'3 puts Mysql::version4Dbc=mysql.real_connect ('127.0.0.1','Root','****','Test')5Res=dbc.query ('Select Id,name from person')6 whilerow=Res.fetch_row Do7Puts"#{row[0]},#{row[1]}"8End
The results are as follows:
20703
1,???
2,jack
3,rose
Ruby on Rails environment to build MySQL database connection