Wednesday, 28 July 2010

Install MySQL from Tar ball

Download your favourite version of MySQL Server from your local mirror. We can use the latest GA (5.1.49) or development release (5.5.5m3). Move your tarball to the /usr/local directory. I'm assuming that you're logged into your box using the root account. If you're not then you might need to utilize sudo.

Add the mysql user and group
   groupadd mysql
   useradd -g mysql mysql

Untar and Create a symbolic link
   cd /usr/local/
   tar -zxvf mysql-{version}.tar.gz
   ln -s mysql-{version} mysql

File and Directory creation/permissions 
   mkdir -p /var/lib/mysql *
   chown -R mysql:mysql /usr/local/mysql
   chown -R mysql:mysql /var/lib/mysql

Install the system databases and place my.cnf
  cp /usr/local/mysql/support-files/my-medium.cnf  /etc/my.cnf**
  cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql***
   scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql --basedir=/usr/local/mysql ****
Start mysqld
   /usr/local/mysql/bin/mysqld_safe &

Check your error log file to keep abreast of any issues that might arise.
Some house keeping is needed to ensure that MySQL will start a boot and also adding mysql into the path. These are basic Linux tasks. Please let me know if you'd like to see my recommendations for these tasks.

* This command is going to create your datadir location. This might not fit your preferences so this is something that you will choose to include or omit. You should review your my.cnf and make any changes to accommodate your desired location.
** This will copy a default my.cnf to the preferred my.cnf location. If you have written your own or have something you wish to use, copy that and not the example file. Your my.cnf is a pretty big deal as it's going configure your server to run like a two-legged dog or Usain Bolt!
*** Enables the 'service mysql [start|stop|status]' command to be executed
**** These parameters can be augmented, omitted or kept. You're going to want to use the values in your my.cnf or change your my.cnf to reflect what you use here.

5 comments:

  1. You should consider reviewing the included my.cnf before use. The configuration files have been really outdated for newer H/W.

    Also I would strongly recommend you ensure the MySQL log file and the MySQL socket file are moved outside of the data directory. This enables better security by being able to have mysql only permissions on /var/lib/mysql

    ReplyDelete
  2. An important step is left out of the install documentation:
    copy support_files/mysql.server to /etc/init.d/mysqld and start/stop mysql as a service, instead of that "/usr/local/mysql/bin/mysqld_safe &"

    ReplyDelete
  3. @Ronald - thanks for your input. I'm thinking about writing a piece on my.cnf and various recommendations around implementing a solid options file. I will certainly ensure the points you've added are utilised.

    @Shlomi - Good point made. I will add amend the original.

    Thanks again guys :-)

    ReplyDelete
  4. So there is no need to configure ,make,make all and make install commands after extracting the tar file.........

    ReplyDelete
  5. Great and useful information comes out through this post.

    ReplyDelete