Setting up a MySQL server

Note that the department now has a central, departmentally managed SQL server that you may use. Just send email to staff@cs.umd.edu to ask about having a database set up for you on this server.

Or, if you prefer to set up and run your own mysql server, continue with the instructions below...


  1. Create a .my.cnf file in your home directory with information about where you'd like your configuration and data files stored:
     
      [client]
      socket=/export/home/derek/.mysql.sock
      [mysqld]
      datadir=/export/home/derek/mysql
      socket=/export/home/derek/.mysql.sock
    
  2. Create the datadir defined in your .my.cnf file if it doesn't already exist:
      $ cd
      $ mkdir mysql 
    
  3. Initialize the database.
      $ mysql_install_db
    
  4. Set a password for the MySQL root user. If you don't perform this step, anyone with access to the running database daemon has full control over the data in your database!
      $ mysqladmin -u root password 'NEWPASSWORD'
    
  5. Start the MySQL daemon
      $ mysqld & 
    
...and you should be good to go.


Notes

For our backup system to backup the database, a mysqldump must be performed. See this link on how to user mysqldump:

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

There are different versions of MySQL available on most department operating systems. Take a look in /usr/local for the one you need and run it explicitly if the default isn't what you want:
  $ ls -d /usr/local/mysql*
  /usr/local/mysql
  /usr/local/mysql-5.0.24a
  /usr/local/mysql-5.0.37
  /usr/local/mysql-5.0.41
  /usr/local/mysql-5.0.45
  /usr/local/mysql-5.1.35

  $ /usr/local/mysql-5.1.35/bin/mysqld &

If you get errors about port 3306 already being bound, someone else is running a MySQL server on that machine on the same port. You'll need to choose a different port. This can be done from the command line when running mysqld:

  $ mysqld --port=3307
or it can be done from the .my.cnf file:
  [client]
  socket=/fs/junkfood/bplecs/.mysql.sock
  [mysqld] 
  datadir=/fs/junkfood/bplecs/mysqld/data
  socket=/fs/junkfood/bplecs/.mysql.sock
  port=3307 


References

See also the MySQL setup documentation.

See also the full MySQL documentation at http://dev.mysql.com/doc/.