Hints, Tips and InstallationBack to Tutorials Ruby In Steel Tutorials Archives Hints, Tips and Installation
Ruby On Rails and MySQL - faster with a Visual Studio shortcut
When starting a Ruby On Rails application, the first step is often the creation of a database. If you use MySQL you may be in the habit of navigating around on disk and running commands from system prompts in order to do this. In fact, you can create a MySQL database with ever leaving Visual Studio. All you need to do is add a MySQL Admin item to the Visual Studio Tools menu. This is how to do it...
Select Tools, External Tools
In the External Tools dialog, click Add
Enter the details shown in the screenshot below in the Title, Command and Arguments fields (here I assume that there is no password and ‘root’ is your user name; if not change it as appropriate). Enter the path to the directory containing mysqladmin.exe in the Initial Directory field.
Check off the ‘Prompt for arguments’ option.
| Note: If you have set a password for use with MySQL, you must add this to the argument list after -p; there must be no spaces between -p and the password. So, if your password were xyz, the complete list of arguments which you would need to supply would be:
-u root -pxyz
Now when you want to create a MySQL database, just select MySQL Admin from the Tools menu.
This pops up a dialog which displays your specified arguments: -u root
Edit this by entering create followed by the name of the database you wish to create (such as, say, ‘railsblog_development’).
This is what you should now see in the dialog:
|Remember, if you are using a password (such as xyz), this needs to be supplied too (in the form: -pxyz).|
When you click OK, the MySQL Admin tool will create the database.
If you prefer to enter database commands at the MySQL Commandline, you can add that to the Tools menu too. Here are the settings I use for this...