How to Create a MySQL Database with MySQL Workbench


Introduction

MySQL workbench is a windows GUI software agent used to administrate MySQL servers and databases, and is often installed by default on a windows server running MySQL, however you can also install it remotely on a client or developer machine. This tutorial illustrates how to create a new database and a new user to access that database on a MySQL Server using phpMyAdmin.

Prerequisites


Using Mysql Workbench Version 5.2

Open the MySQL Workbench software.

Image

DOUBLE-Click on your MySQL instance under the SQL Development section of Workbench to create a new schema.

NOTE: Databases are called schema's in MySQL Workbench.

Image

MySQL workbench may require a login to your MySQL server. Enter your root or user and password that has been assigned dba server privileges.

Image

Click on the New Schema icon in the menu, and then enter a name for your new database in the field as shown. Click the Apply button to generate the SQL script.

Image

Image

Click the Apply button again to execute the create database statement, and create your new database.

Image

Click Finish.

Image

Your database should now be listed on the left with your other database schemas.

Image

Click the Home icon in the top left corner to return to the Workbench Central screen. Click on your MySQL server instance under the Server Administrator section of MySQL workbench to create a new database user and assign privileges to your new database.

Image

Click on Users and Privileges. Then click on Add Account. Enter a login name for the new user, type localhost and a new password as shown. Click Apply to create the new user account.

Image

To assign privileges for this user to access a specific database, click on the Schema Privileges tab. Click the user account from the list of users on the left. Click the Add Entry button.

Image

Select the Selected Schema radio option, and choose your database schema from the list.

Image

Select the appropriate privileges to allow the user access to the selected database. Most modern website software will only require the permissions listed below. Click Save Changes to complete your new user setup.

Select, Insert, Update, Delete, Create, Alter, Index, Drop, Create Temporary Tables, Lock Tables

Image

You can now test your new user login by using MySQL Workbench with your newly created user account.