Creating a MySQL Server Instance Profile with a Database and User
Assuming that you have a MySQL Server installation on your machine, it is normally necessary to configure both a Server Instance Profile, and at least one database to be used within that Instance Profile. Â The following steps walk through the necessary steps to do this, using an example of creating a Database that could be used for a TeamCity installation. Â Some of the steps are specific to this end goal, however, the steps should be generic enough that they can be tailored to your needs.
Configuration Steps
**NOTE: **The following installation steps and screenshots were taken from a virtual machine  with Windows Server 2008 R2 Service Pack 1, running in Hyper-V on a Windows 8 Host Machine.
- Assumption is that you already have MySQL Community Server installed
- Assumption is that you already have MySQL Workbench installed
- Open MySQL Workbench
- Click on the âNew Server Instanceâ link
- In the âSpecify Host Machineâ Window leave as default and click Next
- In the âDatabase Connectionâ Window leave as default and click Next
- On the âTest DB Connectionâ Window ensure that all tested passed and click Next
- Before the next step, we need a Configuration File that MySQL Server can use to instantiate the Server Instance. Â The default MySQL Server installation comes with pre-configured configuration files, located at C:\Program Files\MySQL\MySQL Server 5.5 (where 5.5. is the version number of MySQL Server you have installed)
- Copy the sample Configuration File that you want to have (I chose my-small) to another location on your hard drive. Â For simplicity I chose the root of the C:\ drive, and I renamed the file to my.ini.
- In the âWindows Managementâ window browse to the location that you copied the configuration file and select it. Press Next.
- In the âTest Settingsâ window ensure that all test passed and click Next
- Click âContinueâ when the âReview Settingsâ pop-up appears
- In the âComplete Setupâ window click Finish
- Once back at the home page of MySQL Workbench, double-click on the instance that you have just created
- In the Admin tab, select âUsers and Privilegesâ and click âAdd Accountâ
- Enter the details for the user that you want to create, in this case I have chosen âteamcityâ as the username and entered a password for this user. Â Once completed, click Apply.
- Go back to the home page of MySQL Workbench by clicking the Home tab
- Double click onto the localhost connection
- Click the Create Schema button, and provide a name for the schema, I have chosen teamcity, and then click Apply
- On the âReview SQL Scriptâ window click Apply
- On the âApply SQL Scriptâ window click Finish
- The recommended Collation and Charset for using TeamCity (the application that is going to be using this database is utf8 - utf8_bin, if you require this, select this in the drop down list and click Apply
- On the âReview SQL Scriptâ window click Apply
- On the âApply SQL Scriptâ window click Finish
- Return to the Admin screen by clicking on that tab
- Select âUsers and Privilegesâ and click on the âSchema Privilegesâ tab and select the User that you want to create a permission for, and then click Add Entry
- In the âNew Schema Privilege Definitionâ window select which hosts you want this user to be able to access the schema from (I have chosen to limit this to localhost, which is the most secure.  Also, map the user to the schema that you want them to access.  Again in this case, I have chosen the teamcity schema, so there is a mapping between the teamcity user and schema.  Once completed, click OK
- Once back at the main window, click âSelect âALLâ to give this user all database permissions (you may want to only select certain options, depending on what you require). Â Once you are happy, click âSave Changesâ
You can see screenshots of each of these steps in the galley at the bottom of this blog post.