mkdir -p /db/mysql
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/var
mkdir -p /usr/local/mysql/data && mkdir -p /usr/local/mysql/run && mkdir -p /usr/local/mysql/log && mkdir -p /usr/local/mysql/var
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /db/mysql/
chown -R mysql.mysql /usr/local/mysql/
yum install -y gcc yum install -y gcc-c++ yum -y install ncurses* yum install -y libtermcap*
./configure --enable-thread-safe-client --enable-assembler --with-server-suffix =" for >>>MySQL Database of Zebra by Yhc<<<" --without-debug --with-extra-charsets=complex --prefix=/usr/local/mysql
make -j 12 && make install
#添加PATH
echo "PATH=\"/usr/local/mysql/bin:\$PATH\"" >> /etc/profile && export PATH="/usr/local/mysql/bin:$PATH"
#strip可执行文件
strip /usr/local/mysql/libexec/mysqld
#添加LIB PATH
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf && ldconfig
#将my.cnf文件cp到/etc目录下
/bin/cp -r /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf && chown mysql:mysql /etc/my.cnf
sed -i 's/skip-federated/#skip-federated/' /etc/my.cnf
cd /usr/local/mysql/bin
ln -s ./mysql ./test_mysql
ln -s ./mysqladmin ./adminmysql
ln -s ./mysql_install_db ./install_db_mysql
ln -s ./mysqld_safe ./safe_mysqld
#初始化Mysql表
cd /usr/local/mysql/bin
./install_db_mysql --user=mysql 或者 ./mysql_install_db --user=mysql --datadir=/db/mysql/
若是多实例的话要分别初始化
./mysql_install_db --user=mysql --datadir=/db/mysql/data1 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data2 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data3 --defaults-file=/etc/my.cnf
启动多实例
启动全部实例:/usr/local/mysql/bin/mysqld_multi start
查看全部实例状态:/usr/local/mysql/bin/mysqld_multi report
启动单个实例:/usr/local/mysql/bin/mysqld_multi start 3306
停止单个实例:/usr/local/mysql/bin/mysqld_multi stop 3306
查看单个实例状态:/usr/local/mysql/bin/mysqld_multi report 3306
# 单个实例启动或关闭
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 2
# 双实例同时启动或关闭
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1,2
# 查看MySQL是否启动
# mysqld_multi --defaults-file=./my.cnf report 1,2
mysql -S /tmp/mysql11.sock 进入第一个库
mysql -S /tmp/mysql22.sock 进入第二个库
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chown -R root /usr/local/mysql && chown -R mysql /usr/local/mysql/var && chgrp -R mysql /usr/local/mysql
阅读(934) | 评论(0) | 转发(0) |