http://blog.csdn.net/abbuggy/article/details/7647110
在《Ruby on Rails,使用关系数据库简介》中我们简要浏览了一下关系数据库的最基本概念,这里我们动手创建一个Rails项目可以使用的数据库。Rails可以与DB2、MySQL、Oracle、Postgres、Firebird以及 SQL Server数据库一起工作。新版Rails已经使用SQLite3作为缺省数据库类型了,但是为了管理方便和通用性的考虑,我依旧使用MySQL来作为数据库。在开始之前请先确保MySQL数据库安装完毕并且将环境变量设置好。
检查MySQL安装正确性。
C:\Windows\system32>mysql --version mysql Ver 14.14 Distrib 5.5.17, for Win64 (x86)
C:\Windows\system32>mysql -u root -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5713 Server version: 5.5.17 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
mysql> SHOW DATABASES; +-------------------------+ | Database | +-------------------------+ | information_schema | | mysql | | performance_schema | | simple_site_development | +-------------------------+ 4 rows in set (0.00 sec) mysql>
mysql> CREATE DATABASE simple_cms_development; Query OK, 1 row affected (0.00 sec) mysql>
mysql> GRANT ALL PRIVILEGES ON simple_cms_development.* TO 'abbuggy'@'localhost' IDENTIFIED BY 'abbuggy'; Query OK, 0 rows affected (0.18 sec) mysql>
C:\Windows\system32>mysql -u abbuggy -p Enter password: ******* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5728 Server version: 5.5.17 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
mysql> use simple_cms_development; Database changed mysql>
http://blog.csdn.net/abbuggy/article/details/7647110