Linux 下 Mysql 源码包安装简述

Linux 下 Mysql 源码包安装简述

1.下载
www.mysql.com 下载所需的 mysql 版本(源码包)
如 mysql-x.x.xx.tar.gz

2.解压、安装
cd /opt
tar -zxvf mysql-x.x.xx.tar.gz
cd mysql-x.x.xx
./configure --prefix=/opt/mysql-x.x.xx
make;make install clean

3.配置
添加用户
useradd -M -d /dev/null -s /sbin/nologin mysql

初始化 mysql
cd /opt/mysql-x.x.xx/bin
./mysql_install_db
cd ..
chown -R mysql:mysql var
chgrp root var

4.测试
cd /opt/mysql-x.x.xx/bin
启动 mysql
./mysqld_safe &
( 注:早些时期的版本这里是  safe_mysqld )

netstat -an | grep LISTEN | grep 3306
如果看到如下一行
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
就说明安装配置均 OK 了
如果没有这行或在启动 mysql 时报错,则检查 /opt/mysql-x.x.xx/var 下的
主机名.err (这里主机名是指主机的名称,可用 hostname 命令察看)

5.编写启动脚本
echo "#! /bin/sh" > /etc/init.d/mysqld
echo " " >> /etc/init.d/mysqld
echo "case /"/$1/" in" >> /etc/init.d/mysqld
echo "    start)" >> /etc/init.d/mysqld
echo "        echo /"Starting mysqld/"" >> /etc/init.d/mysqld
echo "        /opt/mysql-x.x.xx/bin/mysqld_safe &" >> /etc/init.d/mysqld
echo "        ;;" >> /etc/init.d/mysqld
echo "    stop)" >> /etc/init.d/mysqld
echo "        echo /"Shutting down mysqld/"" >> /etc/init.d/mysqld
echo "        killall /opt/mysql-x.x.xx/libexec/mysqld" >> /etc/init.d/mysqld
echo "        ;;" >> /etc/init.d/mysqld
echo "    restart|reload)" >> /etc/init.d/mysqld
echo "        /$0 stop  &&  /$0 start" >> /etc/init.d/mysqld
echo "        ;;" >> /etc/init.d/mysqld
echo "    *)" >> /etc/init.d/mysqld
echo "        echo /"Usage: /$0 {start|stop|restart|reload}/"" >> /etc/init.d/mysqld
echo "        exit 1" >> /etc/init.d/mysqld
echo "esac" >> /etc/init.d/mysqld
echo "exit 0" >> /etc/init.d/mysqld

chmod 750 /etc/init.d/mysqld

cd /etc/rc3.d
ln -s ../init.d/mysqld S88mysqld

完成

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭