IT Connect
Information technology tools and resources at the UW

Install MySQL

Set up MySQL

  1. MySQL requires occasional maintenance. Be sure to read and understand the Guidelines and Considerations when Running MySQL.
  2. If you haven’t already done so, you’ll need to activate the Shared Web Hosting service.
  3. Faculty, Staff, Courses and Departments: Set up a localhome if you haven’t yet.  Set up Localhome.
  4. Log into your web development server using a terminal emulator. If you’re not sure how, click here for instructions.
  5. First, you will need to identify a ‘port’ which will be the address for your MySQL instance. Start by choosing a port number and then test to see if that port number is available.  The number must be between 1,024 and 65,000.  Next test the availability of your port number by typing this line at the command prompt:

    telnet localhost number

    Example: telnet localhost 12345

    • If you see “connection refused,” then SUCCESS, you have discovered an available port!  Although this may seem contrary, write down this number and continue to the next step.
      • Anything but “connection refused” means that the port is already in use by an active process and is not available.
    • Explanation: Each MySQL server requires a unique UNIX port in order to work properly.  Although counter-intuitive, unused ports refuse connections and in-use ports ‘listen to’ and accept connections.  Trying to set up MySQL server on a port that is already being used will cause the server to fail to start, generating an error message.
  6. Now, type the following command:
     mysql-local-setup 

    • The script will ask if you would like to install mysql, just type ‘y’ and hit enter to continue.
    • The script will find an open port, but be sure and write this number down for use with other programs such as WordPress.
    • The script will ask you to create a new password for the ‘root’ user and then to re-enter it again.  You will also be given the option to display the password.  Again, be sure to write this one down for future use.
    • Finally, the script will start up MySQL and give you the port number (again) and the host name.  Again, this is something that you will want to write down for later use.
    • Explanation: The script installs the base data files and information into your new MySQL server.

Once the script has finished running, verify that MySQL is responding by typing the following into the command prompt:

~/mysql/bin/mysqladmin -u root -p version

  • You’ll be prompted for the root password again.

If MySQL is running, a message similar to the following will be displayed:

Enter password:
/rc00/d21/accountname/mysql/bin/mysqladmin Ver 8.42 Distrib 5.6.39, for linux-glibc2.12 on x86_64
Copyright (c) 2000, 2018, 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.

Server version 5.6.39
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /rc00/d21/accountname/mysql.sock
Uptime: 2 min 42 sec

Threads: 1 Questions: 7 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.043 

Special Note: If  the root user needs to be able to connect from %.washington.edu, (such as the web servers) then login to mysql:

~/mysql/bin/mysql -u root -p

Run this command:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%.washington.edu' WITH GRANT OPTION;

For more info: learn more

Recommended Options:

Set up an automated script to restart your MySQL server in case the host system reboots by using a cron job: learn more

Without setting up a cron job, your website may be down until you manually restart your server following a system reboot.

Set up an automated backup script in case data recovery is needed: learn more

MySQL requires a special backup script to be configured to prevent damage to the database copies created during backup.

A MySQL server is now running in your account and is ready to accept connections. At this point you can learn about MySQL administration to get more familiar with MySQL, and you can install phpMyAdmin to help you administer your new database server.

Last reviewed January 21, 2020