Slackware 13.0 - Installing MySQL 5.5.22 ======================================== Public domain ******************************************************************************** ### Remove mysql package removepkg mysql ******************************************************************************** ### Create mysql user groupadd mysql useradd -r -g mysql mysql ******************************************************************************** ### Source extraction cd /usr/src wget http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/mysql-5.5.22.tar.gz tar xf mysql-5.5.22.tar.gz cd mysql-5.5.22 ******************************************************************************** ### Check compile options cmake . -LH ******************************************************************************** ### Compile and Install cmake . \ -DCMAKE_INSTALL_PREFIX=/storage/mysql-5.5.22/ \ -DMYSQL_DATADIR=/storage/database/ \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DINSTALL_LAYOUT=STANDALONE \ -DENABLED_PROFILING=ON \ -DMYSQL_MAINTAINER_MODE=OFF \ -DWITH_DEBUG=OFF \ -DWITH_SSL=yes make && make install ******************************************************************************** ### prepair database cd /storage/ mkdir -p ./database chown -R mysql ./database chgrp -R mysql ./database cd /storage/mysql-5.5.22/ chown -R mysql . chgrp -R mysql . scripts/mysql_install_db --user=mysql --datadir=/storage/database chown -R root . egrep -v '^#|^ *$' support-files/my-medium.cnf > /etc/my.cnf ******************************************************************************** ### Comment out binary log in /etc/my.cnf [client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M #log-bin=mysql-bin #binlog_format=mixed server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout ******************************************************************************** ### Start mysqld for the first time /storage/mysql-5.5.22/bin/mysqld_safe --user=mysql --datadir=/storage/database --pid-file=/storage/database/mysql.pid --skip-networking & ******************************************************************************** ### Secure installation wizard /storage/mysql-5.5.22/bin/mysql_secure_installation Enter current password for root (enter for none): Set root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] n Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y ******************************************************************************** ### Startup script: /etc/rc.d/rc.mysqld #!/bin/sh # # /etc/rc.d/rc.mysqld # #!/bin/sh BASEDIR="/storage/mysql-5.5.22" DATADIR="/storage/database" PID="${DATADIR}/mysql.pid" # Disable networking #SKIP="--skip-networking" # Start mysqld: mysqld_start() { # Remove stale pid file if [ -r ${PID} ]; then if ! ps ax | grep -v grep | egrep -q 'mysqld'; then echo "Cleaning up stale pid file: ${PID}" rm -f ${PID} fi fi ${BASEDIR}/bin/mysqld_safe --user=mysql --datadir=${DATADIR} --pid-file=${PID} $SKIP & } # Stop mysqld: mysqld_stop() { # If there is no PID file, ignore this request... if [ -r ${PID} ]; then killall mysqld # Wait at least one minute for it to exit, as we don't know how big the DB is... for second in $(seq 1 60); do if [ ! -r ${PID} ]; then break; fi sleep 1 done if [ "$second" == "60" ]; then echo "WARNING: Gave up waiting for mysqld to exit!" sleep 15 fi fi } # Restart mysqld: mysqld_restart() { mysqld_stop mysqld_start } case "$1" in 'start') mysqld_start ;; 'stop') mysqld_stop ;; 'restart') mysqld_restart ;; *) echo "usage $0 start|stop|restart" esac ******************************************************************************** ### Normal startup chmod +x /etc/rc.d/rc.mysqld /etc/rc.d/rc.mysqld restart ******************************************************************************** ### Simple mysql firewall: /etc/rc.d/rc.firewall #!/bin/bash # Flush previous rules iptables -F iptables -X # MySQL Server iptables -N MYSQL-CHECK iptables -A MYSQL-CHECK -j DROP -m comment --comment "mysql: deny everything else" iptables -A INPUT -p tcp --dport 3306 -j MYSQL-CHECK iptables -I MYSQL-CHECK -s 192.168.1.111 -j RETURN -m comment --comment "mysql: accept trusted station" ******************************************************************************** ### databse root user network access: mysql -p use mysql; select host, user from user; update user set host='192.168.1.%' where user='root' and host='HOSTNAME'; flush privileges; ******************************************************************************** ### Remote connection check mysql -h 192.168.1.10 -u root -p ******************************************************************************** ### links http://downloads.mysql.com/archives.php?p=mysql-5.5&o=other http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.22.tar.gz http://dev.mysql.com/doc/refman/5.1/en/source-installation.html ******************************************************************************** _BY: Pejman Moghadam_ _TAG: mysql, firewall_ _DATE: 2012-04-30 11:21:19_