MySQL Installation

Installation
Download the latest version, which was 5.5.46 at the time of writing.

cd /extra/src
wget -O mariadb-5.5.46.tar.gz https://downloads.mariadb.org/f/mariadb-5.5.46/source/mariadb-5.5.46.tar.gz/from/http:/mirror.jmu.edu/pub/mariadb?serve
tar zxf mariadb-5.5.46.tar.gz
cd mariadb-5.5.46.tar.gz

Add a group and user for the mysql daemon. For a Linux system:

groupadd mysql
useradd -g mysql mysql

At this point, we don't need any advanced options, so our configuration options are simply - just the install path:

./configure --prefix=/usr/local/mysql --with-plugins=innobase

If configure complains No curses/termcap library found then:

yum install ncurses-devel

If it configures without errors, make and install the binaries:

make
make install

Copy the default preferences file:

cp support-files/my-medium.cnf /etc/my.cnf

Because we compiled and installed as root, we need to change the ownership on the installed files so that the mysql user can access them:

cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

Create the MySQL data directory and initialize the user tables. In order to get this to run with 5.1.29-rc, I had to edit /etc/my.cnf and comment out the skip-federated line.

script/mysql_install_db --user=mysql

While most of the installation can be owned by root, the data directory must be owned by the mysql user:

chown -R root .
chown -R mysql var

To test out the installation, start up the MySQL server:

bin/mysqld_safe --user=mysql &

Post-Installation Setup
More detailed instructions available at MySQL's Securing the Initial MySQL Accounts page.
If you prefer, the anonymous account could be removed:

/usr/local/mysql/bin/mysql -u root
DELETE FROM mysql.user WHERE User = '';
FLUSH PRIVILEGES;

Otherwise, assign passwords to the anonymous accounts

/usr/local/mysql/bin/mysql -u root
SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
SET PASSWORD FOR ''@'127.0.0.1' = PASSWORD('newpwd');
SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');

If you don't know the value of host_name, you can get it using:

SELECT Host, User FROM mysql.user;

Now assign passwords to the root accounts:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

Flush the privileges to make sure our changes take effect:

FLUSH PRIVILEGES;
exit

If you ever forget the the root password, instructions for how to reset it are here.
Stop the MySQL daemon:

killall mysqld

Automatic startup
We're going to use daemontools.
If you haven't already, install daemontools.

Create a directory for the MySQL service:

mkdir -m 1755 /var/service/mysql
cd /var/service/mysql

Create the /var/service/mysql/run script, making sure to change the servername:

#!/bin/sh
exec 2>&1
exec \
/usr/local/bin/setuidgid mysql \
/usr/local/mysql/bin/mysqld \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data \
--user=mysql \
--pid-file=/usr/local/mysql/data/<servername>.pid \
--skip-external-locking \
--port=3306 \
--socket=/tmp/mysql.sock

Make the script executable:

chmod 755 run

Our log script comes from John Simpson's:

mkdir -m 755 log
cd log
wget http://qmail.jms1.net/scripts/service-any-log-run
mv service-any-log-run run
chmod 755 run

Finally, add the service to daemontools by creating the symbolic link in /service

ln -s /var/service/mysql /service/mysql

Confirm that the service is running:

svstat /service/mysql /service/mysql/log

Recent Updates

  • 11 months 3 weeks ago
  • 11 months 3 weeks ago
    Removed original versions of ucspi-tcp and ucspi-ssl and replaced them with upgraded versions. The old ones were failing PCI compliance tests by Security Metrics. ucspi-ssl also had issues installing on CentOS 7 - new version installed without issues.
  • 11 months 3 weeks ago
    1.3.7 update
  • 11 months 3 weeks ago
  • 1 year 1 hour ago
    MariaDB