# MySQL
# =====
# As of Slackware-current 2013-03-23, MySQL has been replaced by MariaDB:
# https://mariadb.org/
# http://en.wikipedia.org/wiki/MariaDB
# ...a drop-in replacement for MySQL. At some point I'm probably going
# to stop updating this in favor of that.
#
# Slackware 12.1: mysql 5.0.51b
# Slackware 12.2: mysql 5.0.67
# Slackware 13.0: mysql 5.0.84
# Slackware 13.1: mysql 5.1.46
# Slackware 13.37: mysql 5.1.56
# Slackware 14.0: mysql 5.5.27
# Prerequisites (for both versions):
# bison
# teTeX (optional; Slackware has a 'tetex' package)
# Perl
# zlib
# OpenSSL (optional; if you specify -DWITH_SSL=system)
# cmake
# Create directories to keep the source and tarballs in:
mkdir -p -m 0700 ~/installed/mysql ~/src/mysql
# Become root
su
# Create a mysql user and a mysql group if you don't already have one.
# Versions of Slackware prior to 7.2b don't include them.
getent group | grep "^mysql:" > /dev/null 2>&1 || groupadd -g 27 mysql
id mysql > /dev/null 2>&1 || useradd -u 27 -g mysql mysql
# Remove the old Msql-Mysql-modules perl module that we don't use any more:
find /usr/lib/perl5/site_perl -type d -name Msql-Mysql-modules \
-exec rm -r {} \; 2> /dev/null
find /usr/lib/perl5/site_perl -type d -name mysql \
-exec rm -r {} \; 2> /dev/null
# If you're upgrading an old version of MySQL, save a
# MySQL dump of all databases into a text file:
mkdir -p -m 0700 ~/backup/mysql
mysqldump -p --all-databases | \
bzip2 -9c > ~/backup/mysql/mysql-$(date +%Y%m%d).sql.bz2
test -f /etc/my.cnf &&
cp -a /etc/my.cnf ~/backup/mysql/my.cnf-$(date +%Y%m%d)
# Become yourself again
exit
# Remove the source and tarball for Msql-Mysql-modules:
find ~/src/mysql -maxdepth 1 -type d -name "Msql-Mysql-modules-*" \
-exec rm -r {} \;
rm -f ~/installed/mysql/Msql-Mysql-modules-*.tar.*
# MySQL 5.7.16 (Generally Available (GA) release)
# ============
# Next time...
# Get it
cd
test -f installed/mysql/mysql-5.6.34.tar.gz &&
mv installed/mysql/mysql-5.6.34.tar.gz .
test ! -f mysql-5.6.34.tar.gz &&
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.6.34.tar.gz
# Extract it
cd src/mysql
find -maxdepth 1 -type d -name "mysql-*" -exec rm -r {} \; 2> /dev/null
tar xzvf ~/mysql-5.6.34.tar.gz
cd mysql-5.6.34
test $UID = 0 && chown -R root:root .
# Patch the sample configuration to run mysqld as user 'mysql':
# (there will be "fuzz", but it should apply)
wget -nc http://englanders.us/pub/linux/patches/my-medium.cnf.sh.patch &&
patch -p0 < my-medium.cnf.sh.patch
# If you've run cmake on this source before and want to start all over
test -f Makefile && make clean
test -f CMakeCache.txt && rm CMakeCache.txt
# The unix socket will be /tmp/mysql.sock unless you configure it to be
# elsewhere. If you do, make sure "socket = " is set to the correct
# location in /etc/my.cnf After MySQL is installed, run
# 'mysql_config --socket' to see where it thinks the socket file is.
#
# You may want to create a symlink from the real one to the desired
# location:
# ln -s /var/run/mysql/mysql.sock /tmp/mysql.sock
# or of /tmp/mysql.sock is the real one:
# ln -s /tmp/mysql.sock /var/run/mysql/mysql.sock
# or if you want it in /var/run instead of /var/run/mysql/:
# ln -s /tmp/mysql.sock /var/run/mysql.sock
#
# or you can configure it to be somewhere else by passing MYSQL_UNIX_ADDR
# to cmake like this:
# cmake . -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock
# You can use 'ccmake .' at the console or cmake-gui in X for a menu of
# configuration choices, or run 'cmake . -LH' to list them
## If you have a Slackware package OpenSSL you should be able to do this:
# cmake . -DWITH_SSL=system
## If you have a source-installed MySQL (/usr/local/ssl), with this version,
## 'system' will not work, so use bundled as shown below. More info here:
## http://bugs.mysql.com/bug.php?id=61619
# Configure and build it
cmake . -DWITH_SSL=bundled
make
# Become root to install it
su
# If you are upgrading and use InnoDB, run this to set slow shutdown for
# full purge and change buffer merge before shutting down
mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
# If you are already running mysqld, shut down the old one with mysqladmin
mysqladmin -u root -p shutdown
# or shut it down with an init script if you have one
test -x /etc/rc.d/rc.mysql && /etc/rc.d/rc.mysql stop
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg mysql
# Slackware package removal would leave behind these (on purpose):
rm -f /etc/rc.d/rc.mysql /etc/mysqlaccess.conf
test -d /var/lib/mysql && rm -r /var/lib/mysql
# Install the new version
make install
# If installed under /usr/local/mysql, this won't do anything until
# you update /etc/ld.so.conf (see below)
ldconfig
# If you will be compiling PHP with MySQL support, are 64-bit, and
# will be using --with-libdir=lib64 for PHP:
ln -s /usr/local/mysql/lib /usr/local/mysql/lib64
# Start the new MySQL server
/usr/local/mysql/bin/mysqld_safe --user=mysql \
--datadir=/usr/local/mysql/data
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+rw .
# Become yourself again
exit
# Save the source for later
cd
rm -f installed/mysql/mysql-*.tar.*
mv mysql-5.6.34.tar.gz installed/mysql/
# Skip down to the Post-install section below
# MySQL 5.5.53 (Previous Generally Available (GA) release)
# ============
# Prerequisites (in addition to those above):
# cmake
# Get it
cd
test -f installed/mysql/mysql-5.5.53.tar.gz &&
mv installed/mysql/mysql-5.5.53.tar.gz .
test ! -f mysql-5.5.53.tar.gz &&
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.53.tar.gz
# Verify tarball w/ sha1sum:
# (this one came from my gpg-verified tarball)
echo "ecebbb96dd6663eb35278d112cb06a855c3c1537 mysql-5.5.53.tar.gz" | \
sha1sum -c
# Extract it
cd src/mysql
find -maxdepth 1 -type d -name "mysql-*" -exec rm -r {} \; 2> /dev/null
tar xzvf ~/mysql-5.5.53.tar.gz
cd mysql-5.5.53
test $UID = 0 && chown -R root:root .
# Patch the sample configuration to run mysqld as user 'mysql':
# (there will be "fuzz", but it should apply)
wget -nc http://englanders.us/pub/linux/patches/my-medium.cnf.sh.patch &&
patch -p0 < my-medium.cnf.sh.patch
# If you've run cmake on this source before and want to start all over
test -f Makefile && make clean
test -f CMakeCache.txt && rm CMakeCache.txt
# The unix socket will be /tmp/mysql.sock unless you configure it to be
# elsewhere. If you do, make sure "socket = " is set to the correct
# location in /etc/my.cnf After MySQL is installed, run
# 'mysql_config --socket' to see where it thinks the socket file is.
#
# You may want to create a symlink from the real one to the desired
# location:
# ln -s /var/run/mysql/mysql.sock /tmp/mysql.sock
# or of /tmp/mysql.sock is the real one:
# ln -s /tmp/mysql.sock /var/run/mysql/mysql.sock
# or if you want it in /var/run instead of /var/run/mysql/:
# ln -s /tmp/mysql.sock /var/run/mysql.sock
#
# or you can configure it to be somewhere else by passing MYSQL_UNIX_ADDR
# to cmake like this:
# cmake . -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock
# You can use 'ccmake .' at the console or cmake-gui in X for a menu of
# configuration choices, or run 'cmake . -LH' to list them
## If you have a Slackware package OpenSSL you should be able to do this:
# cmake . -DWITH_SSL=system
## If you have a source-installed MySQL (/usr/local/ssl), with this version,
## 'system' will not work, so use bundled as shown below. More info here:
## http://bugs.mysql.com/bug.php?id=61619
# Configure and build it
cmake . -DWITH_SSL=bundled
make
# Become root to install it
su
# If you are upgrading and use InnoDB, run this to set slow shutdown for
# full purge and change buffer merge before shutting down
mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
# If you are already running mysqld, shut down the old one with mysqladmin
mysqladmin -u root -p shutdown
# or shut it down with an init script if you have one
test -x /etc/rc.d/rc.mysql && /etc/rc.d/rc.mysql stop
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg mysql
# Slackware package removal would leave behind these (on purpose):
rm -f /etc/rc.d/rc.mysql /etc/mysqlaccess.conf
test -d /var/lib/mysql && rm -r /var/lib/mysql
# Install the new version
make install
# If installed under /usr/local/mysql, this won't do anything until
# you update /etc/ld.so.conf (see below)
ldconfig
# If you will be compiling PHP with MySQL support, are 64-bit, and
# will be using --with-libdir=lib64 for PHP:
ln -s /usr/local/mysql/lib /usr/local/mysql/lib64
# Start the new MySQL server
/usr/local/mysql/bin/mysqld_safe --user=mysql \
--datadir=/usr/local/mysql/data
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+rw .
# Become yourself again
exit
# Save the source for later
cd
rm -f installed/mysql/mysql-*.tar.*
mv mysql-5.5.53.tar.gz installed/mysql/
# Be aware that older versions used /usr/local/mysql/var and newer ones
# use /usr/local/mysql/data instead. You may need to move things around,
# and do a spring cleaning under /usr/local/mysql after an upgrade from an
# older major release.
# Add /usr/local/mysql/bin to the PATH and /usr/local/mysql/man to the
# MANPATH. This howto used to add these to /etc/profile, so if they're
# already set there, either remove it and do this, or just skip this.
echo '#!/bin/sh' > /etc/profile.d/mysql.sh
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile.d/mysql.sh
echo 'export MANPATH=$MANPATH:/usr/local/mysql/man' >> /etc/profile.d/mysql.sh
chmod +x /etc/profile.d/mysql.sh
# Read those variables into your current shell
. /etc/profile.d/mysql.sh
# Add /usr/local/mysql/lib to /etc/ld.so.conf, if it's not already in there:
egrep -q "^/usr/local/mysql/lib$" /etc/ld.so.conf > /dev/null 2>&1 ||
( echo "/usr/local/mysql/lib" >> /etc/ld.so.conf ; ldconfig )
# The unix socket will be /tmp/mysql.sock unless you configured it to be
# elsewhere with cmake above. If you did change it, make sure "socket = "
# is set to the correct location in /etc/my.cnf Now that MySQL has
# been installed, you can run 'mysql_config --socket' to see where it thinks
# the socket file is.
#
# Some things using MySQL may assume /tmp/mysql.sock, some may assume
# /var/run/mysql/mysql.sock, especially if you've had some things installed
# for years. To cover those two possibilities, try this, which assumes
# that /tmp/mysql.sock is the real socket file:
mkdir -p -m 0700 /var/run/mysql
chown mysql /var/run/mysql
test ! -L /var/run/mysql/mysql.sock &&
ln -sf /tmp/mysql.sock /var/run/mysql/mysql.sock
# If you do not already have a /etc/my.cnf, you can get a sample from
# /usr/local/mysql/support-files/. my-small.cnf, my-medium.cnf,
# my-large.cnf, my-huge.cnf, ... Do not use my-huge.cnf if you don't
# have >= 1GB of RAM, see the notes at the top. Add a "user = mysql" line
# to the [mysqld] section before you start mysqld for the first time.
# I have a patch that will do that for my-medium.cnf here (expect "fuzz"):
# http://englanders.us/pub/linux/patches/my-medium.cnf.sh.patch
# Copy my-huge.cnf in to place as /etc/my.cnf if you don't have a my.cnf,
# display the differences between yours and this one if you do.
test -f /etc/my.cnf &&
( cd /usr/local/mysql/support-files
diff -q my-huge.cnf /etc/my.cnf || cp my-huge.cnf /etc/my.cnf.new )
test ! -f /etc/my.cnf &&
cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
# Install an init script, create the 'mysql' database if it doesn't already
# exist, and fix the ownership and permissions of the files in
# /usr/local/mysql:
cd /usr/local/mysql
cp support-files/mysql.server /etc/rc.d/rc.mysqld
chmod 700 /etc/rc.d/rc.mysqld
test $(ls -1 data/mysql/ 2> /dev/null | wc -l) -eq 0 &&
scripts/mysql_install_db --user=mysql
chown -R root:mysql .
chown -R mysql data
# If you have older scripts that used to refer to rc.mysql instead of
# rc.mysqld, or it's just an old habit:
ln -sf /etc/rc.d/rc.mysqld /etc/rc.d/rc.mysql
# If you just upgraded, run this:
/usr/local/mysql/bin/mysql_upgrade -u root -p
# If you just upgraded from 4.0.x to 4.1.x, run this.
# Replace 'yourpassword' with your actual password. It should work without
# "--password=" as the previous version did, but that is deprecated.
# mysql_upgrade will run this this too.
test -d /usr/local/mysql/bin/mysql_fix_privilege_tables &&
/usr/local/mysql/bin/mysql_fix_privilege_tables -u root -p
# If you have a recent version of MySQL, you can run this to set the
# root password, and remove the test database (after mysqld is running)
/usr/local/mysql/bin/mysql_secure_installation
#
# If you don't...
# If this is a new installation, set root's MySQL password. When it asks
# for a password the 2nd time, type in the one you entered for the first
# one. Replace 'new-password' with the actual password you want to use.
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h `hostname -s` -p\
password 'new-password'
# Slackware 9.1 and up are already set to run '/etc/rc.d/rc.mysqld start'
# on boot-up (from rc.M) and '/etc/rc.d/rc.mysqld stop' on shut-down (rc.0)
# and reboot (rc.6). You'll want to open up rc.6 (rc.0 is a symlink to it)
# and fix the location of the mysqld.pid file to:
# /usr/local/mysql/data/$(/bin/hostname -s).pid
#
# With this MySQL-provided init-script, make sure rc.M and rc.6/rc.0 run
# it without ". ", or that they run it in the background as a sub-shell.
# Due to the "exit 0" at the end of it, that would cause rc.M to stop
# altogether when it sources rc.mysqld - that would be bad. ...or I
# suppose you could comment out the "exit 0" in rc.mysqld too (and never
# forget to do that after an upgrade). I usually use something like this
# in /etc/rc.d/rc.M:
# if [ -x /etc/rc.d/rc.mysqld ]; then
# rm -f /usr/local/mysql/data/$(hostname -s).pid
# /etc/rc.d/rc.mysqld start
# ln -sf /tmp/mysql.sock /var/run/mysql/mysql.sock
# fi
#
# If you use a really old version of Slackware and your rc.(M|0|6) scripts
# don't run rc.mysqld if it exists, open up rc.local and add something to it
# like this next blurb to start it on boot-up. Make sure you put it before
# apps that use MySQL. If you run Apache + PHP or Radius and they use MySQL
# databases, then you may want to add it to their init scripts instead.
#
# if [ -x /etc/rc.d/rc.mysqld ]; then
# /etc/rc.d/rc.mysqld start
# fi
#
# and you can create/update rc.local_shutdown to handle halt, poweroff
# and reboot if rc.(0|6) doesn't handle it.
#
# if [ -r "/usr/local/mysql/data/$(/bin/hostname -s).pid" -a
# -x /etc/rc.d/rc.mysqld ]; then
# /etc/rc.d/rc.mysqld stop
# fi
# Install these prerequisites of DBD::mysql (installed below):
perl -MCPAN -e shell
o conf make_install_arg UNINST=1
o conf prerequisites_policy follow
install Bundle::CPAN
install Bundle::DBI
exit
# Become yourself again
exit
# Add MySQL's bin directory to your current (non-root) shell's PATH and the
# man dir to your MANPATH, if they're not already set:
echo $PATH | grep -q "/usr/local/mysql/bin" ||
export PATH=$PATH:/usr/local/mysql/bin
echo $MANPATH | grep -q "/usr/local/mysql/man" ||
export MANPATH=$MANPATH:/usr/local/mysql/man
## DBD::mysql (Perl module)
# Get it
cd
test -f installed/mysql/DBD-mysql-4.038.tar.gz &&
mv installed/mysql/DBD-mysql-4.038.tar.gz .
test ! -f DBD-mysql-4.038.tar.gz &&
wget http://cpan.perl.org/modules/by-module/DBD/DBD-mysql-4.038.tar.gz
# Extract it
cd src/mysql
find -maxdepth 1 -type d -name "DBD-mysql-*" -exec rm -r {} \;
tar xzvf ~/DBD-mysql-4.038.tar.gz
cd DBD-mysql-4.038
test $UID = 0 && chown -R root:root .
find -type f -exec chmod 644 {} \;
# 'make test' needs your MySQL root password (if you have one set) to be
# able to run tests. Replace 'yourpassword' below with your actual MySQL
# root password. We'll clean up work files and your shell history so it's
# not stored anywhere.
#
# If you ran mysql_secure_installation above and removed the 'test' db,
# don't be surprised when that fails for 'make test'.
perl Makefile.PL --testuser=root --testpassword=yourpassword
make
make test
su -c "make install"
# Clean up files, like the one with your password in it
make distclean
# Zap your shell history, including the command with your password in it
history -cr
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+rw .
# Save the source for later
cd
rm -f installed/mysql/DBD-mysql-*.tar.*
mv DBD-mysql-4.038.tar.gz installed/mysql/
# Make sure you reinstall DBD::mysql every time you upgrade MySQL because
# of libmysqlclient.so changes. Read "perldoc DBD::mysql" for more info
# about using this module.
# If you want a web GUI for MySQL administration, you may want to look at
# phpMyAdmin