# MariaDB 10.2.31 - Stable (GA) release (from 2017-xx-xx)
# ===============
# When migrating from MySQL to MariaDB, your best bet is going from
# MySQL 5.7.x to MariaDB 10.2.x
# Get it
cd
test -f installed/mariadb-10.2.31.tar.gz &&
mv -f installed/mariadb-10.2.31.tar.gz .
test ! -f mariadb-10.2.31.tar.gz &&
wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.31/source/\
mariadb-10.2.31.tar.gz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "mariadb-*" -exec rm -r {} \;
tar xzvf ~/mariadb-10.2.31.tar.gz
cd mariadb-10.2.31
test $UID = 0 && chown -R root:root .
# Read README.md, BUILD-CMAKE
# Create a build directory
mkdir build-mariadb
cd build-mariadb
# If you've run CMake before, clean up
test -f Makefile && make clean
test -f CMakeCache.txt && rm CMakeCache.txt
# List all configuration options
cmake .. -LH | less
# By default the mysql.sock socket file is located in /tmp
# If you want it accessible as another path, create a symlink as root:
# su -c "ln -s /tmp/mysql.sock /var/run/mysql.sock"
# or tell CMake where it should go, then that will be the new default:
# -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock
# For OpenSSL in /usr or /usr/local (if PATH and /etc/ld.so.conf know it):
# -DWITH_SSL=system
# For OpenSSL <= 1.0.2 installed under /usr/local/ssl (OK for lib or lib64):
# -DWITH_SSL=/usr/local/ssl
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
cmake -DINSTALL_LIBDIR=lib64 -DINSTALL_PLUGINDIR=lib64/plugin ..
# Configure the build for anything else
test $(uname -m) != 'x86_64' && cmake ..
# Build it
make
# Become root to install it
su
# Source /etc/profile.d/mysql.sh if it's there to get PATH and MANPATH
# udpated for MariaDB
test -f /etc/profile.d/mysql.sh && . /etc/profile.d/mysql.sh
# If you're upgrading an old version of MySQL or MariaDB, save a dump of all
# databases into a text file:
mkdir -p -m 0700 ~/backup/mariadb
mysqldump -p --all-databases | \
xz -9c > ~/backup/mariadb/mysql-$(date +%Y%m%d).sql.xz
# If you are already running mysqld, shut down the old one with mysqladmin
mysqladmin ping && mysqladmin -u root -p shutdown
# ...or shut it down with an init script if you have one
test -x /etc/init.d/mysql && /etc/init.d/mysql stop
test -x /etc/rc.d/rc.mysqld && /etc/rc.d/rc.mysqld stop
# Save a copy of the existing configuration files
test -f /etc/my.cnf &&
( cd /etc
tar cJvf ~/backup/mysql/my.cnf-$(date +%Y%m%d).tar.xz \
my.cnf mysqlaccess.conf my.cnf.d/* )
# If upgrading, you may also want to tar up the database files
# /usr/local/mysql/data or (/var/lib/mysql) at least temporarily copy
# them to another path until the upgrade is done and confirmed OK
# Because it is a drop-in replacement, remove both the mysql and mariadb
# Slackware packages
test -x /sbin/removepkg && /sbin/removepkg mysql mariadb
# Slackware package removal would leave behind these (on purpose)
# Only do this if cleaning up after an old version and you backed up
# everything you need, or will create new ones below
rm -f /etc/logrotate.d/mysql /etc/rc.d/rc.mysqld /etc/my.cnf \
/etc/mysqlaccess.conf
test -d /etc/my.cnf.d && rm -r /etc/my.cnf.d
test -d /var/lib/mysql && rm -r /var/lib/mysql
# If a new installation, add /usr/local/mysql/lib* to /etc/ld.so.conf
for libdir in lib64 lib;
do
egrep -q "^/usr/local/mysql/${libdir}$" /etc/ld.so.conf ||
( test -d /usr/local/mysql/${libdir} &&
echo /usr/local/mysql/${libdir} >> /etc/ld.so.conf )
done
# The mariadb.pc pkg-config file would end up in
# /usr/local/mysql/share/pkgconfig as things are done above
# (and libmariadb.pc would go in lib/pkgconfig - ?)
# Change that to /usr/local/mysql/lib*/pkgconfig
( LIBDIR=lib
test $(uname -m) = 'x86_64' && LIBDIR=lib64
cd support-files
test ! -f cmake_install.cake.old &&
cp -a cmake_install.cmake cmake_install.cmake.old
cat cmake_install.cmake.old |
sed "s%/share/pkgconfig%/${LIBDIR}/pkgconfig%" > cmake_install.cmake
unset LIBDIR )
# Install the new version
make install
ldconfig
# Create a mysql user and group if you don't already have them
# (uid 27 and gid 27 are not required, only to keep them the same on
# multiple machines for me)
getent group | grep "^mysql:" > /dev/null 2>&1 || groupadd -g 27 mysql
id mysql > /dev/null 2>&1 || useradd -u 27 -g mysql mysql
# Error logging to a file is enabled by default. The log file should
# be /usr/local/mysql/data/$(hostname -s).err
# unless you define log-error in /etc/my.cnf.d/server.cnf in a [mysqld]
# section or one of the other ways that works (see
# "mysqld Configuration Files and Groups" - link above).
#
# First set it up so mysqladmin can run as *nix-account root, using MariaDB
# account root, without specifying a password. Replace my_password with
# your actual MariaDB root password. To make this work for all clients,
# mysqldump, mysqladmin, etc. use [client] instead.
test ! -f /root/.my.cnf &&
( echo -e "[mysqladmin]\npassword=my_password" > /root/.my.cnf
chmod 600 /root/.my.cnf )
#
# To set up logrotate to rotate the MariaDB error log, create a
# /etc/logrotate.d/mysql like so:
cat <<EOF > /etc/logrotate.d/mysql
/usr/local/mysql/data/$(hostname -s).err {
notifempty
daily
rotate 3
missingok
compress
postrotate
if test -x /usr/local/mysql/bin/mysqladmin && \\
/usr/local/mysql/bin/mysqladmin ping > /dev/null 2>&1
then
/usr/local/mysql/bin/mysqladmin flush-logs
fi
endscript
}
EOF
chmod 600 /etc/logrotate.d/mysql
# If your Slackware has rc.sysvinit, create /etc/init.d/mysqld, or use
# rc.mysqld as done below to start mysqld at boot-up and shut-down/reboot
test -d /etc/init.d &&
( cd /etc
cp /usr/local/mysql/support-files/mysql.server init.d/mysql
chmod 700 init.d/mysql
test -d rc0.d && ln -sf init.d/mysql rc0.d/K36mysql
test -d rc3.d && ln -sf init.d/mysql rc3.d/S64mysql
test -d rc4.d && ln -sf init.d/mysql rc4.d/S64mysql
test -d rc5.d && ln -sf init.d/mysql rc5.d/S64mysql
test -d rc6.d && ln -sf init.d/mysql rc6.d/K36mysql )
# If your Slackware does not have rc.sysvinit, or you prefer the usual
# rc.mysqld instead, use MariaDB's provided mysql.server script as
# /etc/rc.d/rc.mysqld
#
# IMPORTANT #1: rc.M and rc.0|rc.6 will handle rc.mysqld, but they source
# it (.), so either change rc.M to run (not source) rc.mysqld, or
# comment-out the "exit 0" line at the end of rc.mysqld
#
# IMPORTANT #2: rc0|rc.6 will only use rc.mysqld if /var/run/mysql/mysql.pid
# exists and is readable. Change that to
# /usr/local/mysql/data/$(hostname -s).pid or wherever you have pid-file
# set to in /etc/my.cnf*
test ! -f /etc/init.d/mysql &&
( cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/rc.mysqld
chmod 700 /etc/rc.d/rc.mysqld )
# Copy sample config files if they do not already exist
# They are only needed to override the default values
test ! -d /etc/my.cnf.d && mkdir /etc/my.cnf.d
( cd ../support-files/rpm
test ! -f /etc/my.cnf && cp my.cnf /etc/
test ! -f /etc/my.cnf.d/client.cnf && cp client.cnf /etc/my.cnf.d/
test ! -f /etc/my.cnf.d/mysql-clients.cnf &&
cp mysql-clients.cnf /etc/my.cnf.d/
test ! -f /etc/my.cnf.d/server.cnf && cp server.cnf /etc/my.cnf.d/ )
# Add /usr/local/mysql/bin to PATH, /usr/local/mysql/man to MANPATH,
# and /usr/local/mysql/share/pkgconfig to PKG_CONFIG_PATH
# (if you use csh, create mysql.csh)
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
for pcdir in lib64 lib share;
do
test -d /usr/local/mysql/${pcdir}/pkgconfig &&
echo "export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:/usr/local/mysql/\
${pcdir}/pkgconfig" >> /etc/profile.d/mysql.sh
done
chmod +x /etc/profile.d/mysql.sh
# Read those variables into your current shell
. /etc/profile.d/mysql.sh
# If this is a new installation
test ! -d /usr/local/mysql/data/mysql &&
( cd /usr/local/mysql
scripts/mysql_install_db --user=mysql )
# If you are migrating from another machine, and you read "Copying
# Tables Between Different MariaDB Databases...", if you are doing it by
# copying the database files, copy them in to /usr/local/mysql/data/
# Safer to not bother, as far as not breaking anything, but you may want to
# try to tighten up permissions and ownership, hopefully without causing any
# issues for your specific setup. If root will be the only user at the
# command line, nobody else needs to get to the man pages and such. You may
# want to use root:mysql for /etc/my.cnf* and chmod -R o-rwx, or mysql:root
# and chmod -R go-rwx, ...
( cd /usr/local/mysql
chown -R root:root .
chown -R mysql data share
chmod -R go-rwx .
chmod 755 bin man man/man?
find include/ -type d -exec chmod 755 {} \;
find lib*/ -type d -exec chmod 755 {} \;
chmod 751 .
find bin/ -type f -executable -exec chmod 755 {} \;
find include/ -type f -exec chmod 644 {} \;
find lib*/ -type f -exec chmod 755 {} \;
find lib*/ -type f -name "*.a" -exec chmod 644 {} \; )
# Start it
test -x /etc/init.d/mysql && /etc/init.d/mysql start
test -x /etc/rc.d/rc.mysqld && /etc/rc.d/rc.mysqld start
# If you are restoring from a dump or anything like that, do that here
# If this is an upgrade, check that tables from old version are OK with new
mysql_upgrade -p
# Secure the installation (see 'man mysql_secure_installation')
mysql_secure_installation
# 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
mkdir -p -m 0700 installed
# Don't remove mariadb-connector-c and others
rm -f installed/mariadb-[[:digit:]]*.tar.*
mv mariadb-10.2.31.tar.gz installed/