Overview of This Lesson

This document explains how to install and setup MySQL Server on your own computer.

Installing and Configuring MySQL Server

MySQL Server allows you to develop and test programs that use databases.

If you installed MySQL more than a few months ago, check the version number: the latest version of MySQL Server Community edition is 8.2.x. If yours is older than that, you should uninstall it and re-install the latest version using the instructions below.

To uninstall MySql, go to Control Panel > Programs and Features and uninstall EVERYTHING to do with MySql - even the MySql Installer.

Once you've uninstalled everything related to MySql, do a registry clean. You'll probably need to download a program to do this, such as AusLogics Registry Cleaner. or CCleaner.

Make sure that you don't install anything extra when you install a free application - many of those installers try to trick you into installing extra things you don't want. READ the screens!!!

After you've cleaned your registry, restart your computer, and then proceed to install MySql Server.

If you DO NOT have MySQL Installed

If you have MySQL already installed, skip this section, unless you don't have the World sample database installed. If you don't have this database, make sure you add it to your existing installation.

Preparing for Installation

There are 2 phases to setting up MySQL server: Installation and Configuration. Both phases are done in a single installation wizard. The instructions below take you through this process step by step. Screen shots have been included for several steps, but have not been included for steps that don't require a lot of action on your part.

Make sure you READ and follow the instructions carefully!!

If you encounter any problems during the installation and setup, ask your professor in class or during email (if emailing, be sure to send a screen shot and full description of the problem).

Download the Installation File

  1. Go to the MySQL Community Downloads page.
  2. Select the most recent version and your operating system. Then click on the Download button for your operating system.
    screen for choosing version and operating system
    Scroll down to select your operating system.
  3. Next page asks you to log in or sign up: you don't need to, just look farther down and click the "No thanks, just start my download" link.
    click the link, don't worry about signing up
    Click the link, don't worry about logging in or signing up.
  4. Save the file to your computer.

The Installation Phase

  1. Go find the file you just downloaded and run it. This begins the installation of MySQL Server.
  2. When prompted, accept the license agreement and click the NEXT button.
  3. Choosing a Setup Type screen: select "Typical" and then click the NEXT button.
    typical button highlighted
    Select Typical Installation.
  4. On the next screen click the Install button.
    install button highlighted
    click the Install button
  5. The next screen indicates that installation is finished. Make sure the checkbox for "Run MySQL Configurator" is checked, then click the FINISH button.
    check box should be checked
    Run the MySQL Configurer

The Configuration Phase

The next set of screens take you through the configuration phase.

list of items you are going to configure
MySql Configurator Screen

Click the NEXT button to begin configuring MySQL Server.

  1. Type and Networking - second screen: Once again, just leave the defaults as they are and click the NEXT button. The defaults should already be set to:
    • Config Type: Development Machine
    • Connectivity: check TCP/IP and check "Open Windows Firewall ports for network access"
    • Port number: 3306
    leave the defaults and click next
    Leave the defaults and click the NEXT button
  2. Accounts and Roles: this screen asks you to set your root account password.
    • First, you must enter a password for the ROOT ACCOUNT. Keep this password handy and don't lose it: you'll need it later.
    • If you ever forget the password, you will have to uninstall and reinstall MySQL.
      add a password for the root account
      Add a password for the ROOT ACCOUNT. Don't lose this password!
  3. Windows Service screen: this screen allows you to configure MySQL Server as a service.
    • Check "Configure MySQL Server as a Windows Service"
    • Windows Service Name: leave the default MySQL82 or change it if you want.
    • The checkbox "Start the MySQL Server at Startup" - it's up to you if you want to check this or not.
      • Checked: The server will always start up when your computer starts up. This comes in handy if you don't want to bother always starting it up manually, but it does take up processing power when you're not using it . If your computer is a couple of years old or less powerful, you might want to uncheck this.
      • Unchecked: you will start the server manually whenever you need to use it. Instructions on how to do this are further down.
    • Under "Run Windows Service as..." select "Standard System Account" (if you know what this is about, feel free to change your selection).
      configure MySQL as a service
      Configure MySQL Server as a Windows Service
      When you're redy, click the NEXT button.
  4. You can leave the defaults on the Server File Permissions screen. Click NEXT.
    leave the defaults
    Server File Permissions
  5. On the Sample Database Screen, check the box for the World Database. This will give us a good database to play with for examples.
    leave the defaults
    Add the World Sample Database
  6. Apply Configuration screen: This lists the series of steps the installation program will perform in order to update your configuration changes so far. Click the EXECUTE button.
    applying configuration options
    Click Execute to apply the configuration settings
  7. You'll see it working its way through each step, just wait until it's finished. Once all steps have been completed, click NEXT button.
    configuration options applied
    The MySQL Server configuration is complete once all the steps have been performed.
  8. When the configuration has completed successfully, you'll see the list of checked-off items marked as completed. Click the NEXT button.
  9. The last screen indicates that you've finally completed the installation and configuration of MySQL Server! Click the FINISH button.

You're finally finished!! MySQL Server is now installed and configured, along with several of its components.

Adding a Guest Account

It's important to note that you should NEVER use a root or admin account in your web databse applications: Your pages are accessible by anyone and you should never use the root or admin account to perform queries. These accounts are all-powerful - they have the ability to view any of the database tables or even modify/delete records in those tables, or modify/delete the tables themselves. You should always use a guest account with minimal access permissions.

To add a guest account, open up the MySQL Command Line Tool: Open a Command Prompt window on your computer and type: mysql -u root -p
This runs the MySQL Command line tool and logs you in as the root user, prompting you for the password. So when prompted, enter the password you set up for the root user during the configuration phase of the installation.

You should now be at the mysql> prompt. Enter the following to create a new guest account:

CREATE USER IF NOT EXISTS 'guest'@'localhost' IDENTIFIED BY 'password';

Make sure you create an actual password to put in place of password!

Now give your guest account whatever permissions it needs on a specific database using the GRANT statement. For example, to only grant permission to perform SELECT queries on the "world" database, you can use:

GRANT SELECT ON world.* TO 'guest'@'localhost';

To give the guest account full CRUD (create, read, update, delete) permissions, you could use:

GRANT SELECT, INSERT, UPDATE, DELETE ON world.* TO 'guest'@'localhost';

This guest account is the one you should use in your code when you are performing the necessary SQL operations on unauthenticated users.