Skip Navigation
IT Connect
Connecting You to Information Technology at the UW

 

Installing MySQL on Shared UW Hosting

IT Connect > Web > Publishing > Using MySQL > Installing MySQL on Shared UW Hosting

UW Information Technology provides support for MySQL through a limited set of documentation for advanced-level, do-it-yourself use, as well as a set of centrally-managed MySQL binaries on the Web development systems.

Set up MySQL

  1. StepsActions
  2. MySQL requires occasional maintenance. Be sure to read and understand the Guidelines and Considerations when Running MySQL.
  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 to do this, click here for instructions.

  5. At the command prompt, type mysql-local-setup

    • In order to get the script to run successfully, you have to answer the prompt by typing the word "yes."
    • Explanation: This command will install and link the central MySQL binaries to your home directory.
  6. Select a number between 1,024 and 65,000 and run telnet localhost number at the command prompt, replacing number with the number you selected.

    • Your number is acceptable if you see "connection refused," write down this number and continue to the next step.
    • You will need to choose and test another number if you see anything but "connection refused," pick another number and try again.
    • Explanation: Each MySQL server requires a unique UNIX port in order to work properly. This step helps you locate an unused port that you can use to set your server up with.
  7. Create and open a new file called .my.cnf in your home directory by typing the following at the command prompt:

    pico ~/.my.cnf

  8. Copy and paste the following lines into the file, replacing the highlighted text with the substitutions listed below:

    [mysqld]
    port=xxxxx
    socket=/hw13/d06/accountname/mysql.sock
    basedir=/hw13/d06/accountname/mysql
    datadir=/hw13/d06/accountname/mysql/data
    innodb=off
    default-storage-engine=myisam

    [client]
    port=xxxxx
    socket=/hw13/d06/accountname/mysql.sock

    • Replace the two instances of xxxxx with the port number you found in step 5. Write this number down if you plan to install phpMyAdmin. This is the port that MySQL will use to listen for connections.

    • Replace /hw13/d06/accountname with the path to your home directory, which you can find by typing echo $HOME at the command prompt.

  9. Save and close the file using Pico. (Click for instructions on how to use pico).

  10. Type the following two lines at the command prompt.

    cd mysql
    scripts/mysql_install_db

    • The mysql_install_db script may take a while to run. The script informs you that a root password should be set. Don't worry about this for now: you will do this in a few more steps.

    • Explanation: These install the base data files and information into your new MySQL server.
  11. Type the following at the command prompt in order to start MySQL.

    bin/mysqld_safe &

  12. Press enter to return to the command prompt.

  13. Set a new root password by typing this at the command prompt.

    bin/mysqladmin -u root password "mypassword"

    • Replace mypassword with a password of your choice.

    • Do not use dollar signs ($) in your password.

  14. This is the root password for your MySQL server. Be sure to write it down.

  15. Type the following command to connect to the server:

    bin/mysql -u root -p

    • Enter the password set up previously in this procedure.

  16. At the mysql> prompt, type the following commands.

    use mysql;
    delete from user where Host like "%";
    grant all privileges on *.* to root@"%.washington.edu" identified by 'mypassword' with grant option;
    grant all privileges on *.* to root@localhost identified by 'mypassword' with grant option;
    flush privileges;

    • Replace "mypassword" with the password you selected earlier in this procedure.

    • Explanation: This step allows other systems, including the web servers, to connect to your MySQL databases.
  17. Check to see that the users were properly set up by running this command:

    mysql> select user,host from mysql.user;

  18. If all went well, you should see the following:

    +------+------------------+
    | user | host             |
    +------+------------------+
    | root | %.washington.edu |
    | root | localhost        |
    +------+------------------+
    2 rows in set (0.00 sec)

    If you see this, move on to the next step. If you don't see something like this, go back and enter the commands in step 15 over again.

  19. Exit the MySQL command line by typing the following into the command prompt:

    mysql> exit;

  20. Verify that MySQL is properly responding by typing the following into the command prompt:

    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:
    /usr/local/mysql/bin/mysqladmin  Ver 8.41 Distrib 5.0.45, for pc-linux-gnu on i686
    Copyright (C) 2000 MySQL AB 
    This software comes with ABSOLUTELY NO WARRANTY. This is free software,
         and you are welcome to modify and redistribute it under the GPL license
    
         Server version          5.0.45-standard
         Protocol version        10
         Connection              Localhost via UNIX socket
         UNIX socket             /hw13/d06/accountname/mysql.sock
         Uptime:                 1 min 20 sec
    
         Threads: 1  Questions: 2  Slow queries: 0  Opens: 11  Flush tables: 1  Open tables: 6                 
         Queries per second avg: 0.025
         
    
  21. 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.

  22. Sign up for MySQL User Mailman lists to be notified regarding server reboots, maintenance, or other information regarding MySQL servers: MySQL User Mailman Lists

  23. 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.

Guidelines and Considerations when Running MySQL

Host system reboots

Host systems may occasionally reboot. If the reboot is scheduled, a notification will be sent to the appropriate MySQL User Mailman List. If a reboot is unexepected or due to system failure, a notification will be sent after the incident to the appropriate MySQL User Mailman List.

Notification

Owners and administrators of a MySQL server may occasionally get communication from UW-IT regarding updates, security concerns, or other information that may be relevant to running a MySQL server. These messages cannot be opted out of if a MySQL server is running on an account that they own or administer.

Maintenance

From time to time, UW-IT may notify administrators of a MySQL server about maintenance or work that they may need to perform in order to resolve issues or keep their server operating.

Be responsible

Your MySQL server is running on a shared server. Please be reasonable when using extremly large databases or queries. If possible, run database-intensive jobs during off-hours.

Shut down when finished

Shut off your MySQL server if you are no longer using it. This helps prevent security issues as well as free up system resources for other users.

Changing jobs?

If changing positions or employeers, please be sure to document or educate your successor about the MySQL server you've been running and how to maintain it.