Information Services

Information Technology Services

Supporting WSU's Academic, Business, Communication and Data Network Services and Systems

Setting up MySQL in wsunix web space

  1. Request a port number from hotseat@wsu.edu.
  2. Create a text file with the following data where <login name> is your wsunix account name.
    • [client]
    • #host = wsunix.wsu.edu
    • port = <Assigned number from step 1>
    • socket = /users/www/<login name>/mysql.socket
    • [mysqld]
    • port = <Assigned number from step 1>
    • socket = /users/www/<login name>/mysql.socket
    • pid-file = /users/www/<login name>/mysql.pid
    • datadir = /users/www/<login name>/<somedirectory>
    • language = /hostlocal/mysql/share/mysql/<english>
  3. Save file as .my.cnf
  4. Using fsecure, ssh or other file transport utility:
    • put .my.cnf /users/www/<login name>
  5. Run the following commands:
    • ln  -s  /users/www/<login name>/.my.cnf  /users/wsunix/<login name>/.my.cnf
    • /hostlocal/mysql/scripts/mysql_install_db
    • /hostlocal/mysql/bin/safe_mysqld &
    • /hostlocal/mysql/bin/mysqladmin password ZZZ
    • ...(Comment: Use something in place of the ZZZ which will become your mysql password)
    • /hostlocal/mysql/bin/mysql
    • grant all on *.* to root@unicorn.it.wsu.edu ;
    • grant all on *.* to root@mistered.it.wsu.edu ;
    • grant all on *.* to root@wsunix.wsu.edu ;
    • grant all on *.* to root@charlotte.it.wsu.edu ;
    • grant all on *.* to root@wilbur.it.wsu.edu ;
    • grant all on *.* to root@www.wsu.edu ;
    • quit
    • /hostlocal/mysql/bin/mysqladmin -u root -pZZZ shutdown
    • ...(Comment: ZZZ is your mysql password)
  6. Edit the .my.cnf file:
    • change:
    • #host =wsunix.wsu.edu
    • to:
    • host = mistered.it.wsu.edu
  7. Run: nohup /hostlocal/mysql/bin/safe_mysqld &

    If you need help with these steps, contact hotseat@wsu.edu

  8. Keeping it running:

    Whenever the host you are running your mysql database on
    goes down, then your mysql database will need to be restarted when
    that system comes back up again.

    You could create a cron entry in your wsunix account to handle this for you.
    It could check every hour and if your database is down, then restart it.

    You could handle it by doing this:

    1. log onto your wsunix account on the system your configuration file points to (either unicorn.it.wsu.edu or mistered.it.wsu.edu)
    2. Create a script that can be run periodically to check and make sure mysql is still running under your account. Lets call it 'is_sql_up.sh' and it would contain these commands:
      • #!/usr/bin/ksh
      • set -x
      • wc=`/sbin/ps -u emc | /sbin/grep -v grep |/sbin/grep safe_mysqld|/usr/bin/wc -l`
      • if [[ ${wc} -ge 1 ]]
      • then
      • exit
      • fi
      • nohup /hostlocal/mysql/bin/safe_mysqld &
    3. once you've created is_sql_up.sh, you set cron up under your own
      account to run periodically. If you want it to run every 30 minutes you'd say:

      crontab -e

    4. At that point you are put into and editor session where you enter your command to run every 30 minutes. First you type the letter "a" to start appending text to the crontab entry, then you enter this line:

      0,30 * * * * /users/wsunix/NAME/is_sql_up.sh > check.log 2>&1

      Where "NAME" is the name of your wsunix account on unicorn or mistered.

      Then you hit the escape key, then you type the string ":wq" without
      the double quotes. This will save your cron entry. From then on,
      every 30 minutes unicorn will check and make sure your mysql server
      is running and it'll restart it if its not running.

Available languages:

Czech, Danish, Dutch, English, Estonian, French, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, Swedish

Information Technology Services, PO Box 641222, Washington State University, Pullman WA 99164-1222 509-335-4357, Contact Us