Configuring MySQL
Config files
/etc/my.cnf, ~/.my.cnf
Configuration Information
There are several default configurations file available in
/usr/share/mysql which you can use.
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
We can now install a database and change the ownership to the
unprivileged user and group.
mysql_install_db
chown -R mysql:mysql /var/lib/mysql
Further configuration requires that the mysql server be running:
mysqld_safe --user=mysql 2>&1 >/dev/null &
A default installation does not setup a password for the administrator
so here we will set one. Replace [new-password]
with your own.
mysqladmin -u root password [new-password] &&
mysqladmin -p flush-privileges
Now that we are done with the configuration of the server, we can
shut it down.
mysqladmin -p shutdown
To automate the running of MySQL, use the following command to create
the init.d script:
cat > /etc/rc.d/init.d/mysql << "EOF"
#!/bin/bash
# Begin $rc_base/init.d/
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
case "$1" in
start)
echo "Starting MySQL daemon..."
/usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
evaluate_retval
;;
stop)
echo "Stopping MySQL daemon..."
killproc mysqld
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
statusproc /usr/sbin/mysqld
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
# End $rc_base/init.d/
EOF
chmod 755 /etc/rc.d/init.d/mysql
Create the symbolic links to this file in the relevant
rc.d directory
with the following commands:
cd /etc/rc.d/init.d &&
ln -sf ../init.d/mysql ../rc0.d/K26mysql &&
ln -sf ../init.d/mysql ../rc1.d/K26mysql &&
ln -sf ../init.d/mysql ../rc2.d/K26mysql &&
ln -sf ../init.d/mysql ../rc3.d/S34mysql &&
ln -sf ../init.d/mysql ../rc4.d/S34mysql &&
ln -sf ../init.d/mysql ../rc5.d/S34mysql &&
ln -sf ../init.d/mysql ../rc6.d/K26mysql
Finally, add this entry to your ld.so.conf
file so that programs which utilize
MySQL can find its
libraries:
echo /usr/lib/mysql >> /etc/ld.so.conf