Centos linux mysql 5.5 script fully automatic source package installation

mysql 5.5 source package download method
https://download.csdn.net/download/weixin_44578029/13765465

mysql-5.5.46.tar.gz

Script content:

#!/bin/sh


# 参数设置
INSTALL_PATH=/usr/local/mysql # 指定安装目录
DATA_PATH=/mnt/datadisk1/mysql # 指定数据目录


if [ -s /etc/my.cnf ];then
rm -rf /etc/my.cnf
fi


echo "----------------------------------start install mysql -----------------------------"
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake
mkdir -p $DATA_PATH
if [ 'grep "mysql" /etc/passwd | wc -l' ]; then
echo "adding user mysql"
groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql
else
echo "mysql user exists"
fi


echo "------------------------------unpackaging mysql -----------------------------------"
tar -xvf mysql-5.5.46.tar.gz
cd mysql-5.5.46


echo "-------------------------configuring mysql,please wait-----------------"
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=$DATA_PATH \
-DMYSQL_USER=mysql


if [ $? -ne 0 ];then
echo "configure failed ,please check it out!"
exit 1
fi


echo "make mysql, please wait for 10 minutes"
make
if [ $? -ne 0 ];then
echo "make failed ,please check it out!"
exit 1
fi


make install


chmod +w $INSTALL_PATH
chown -R mysql:mysql $INSTALL_PATH
ln -s $INSTALL_PATH/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
cd support-files/
cp my-large.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
sed -i 's#^thread_concurrency = 8#& \ndatadir = '$DATA_PATH' \nbasedir = '$INSTALL_PATH' \nlog-error = '$INSTALL_PATH'/mysql_error.log \npid-file = '$INSTALL_PATH'/data/mysql.pid \ndefault-storage-engine=MyISAM \nuser = mysql#g' /etc/my.cnf
$INSTALL_PATH/scripts/mysql_install_db --user=mysql --basedir=$INSTALL_PATH --datadir=$DATA_PATH
chmod +x /etc/init.d/mysqld


sed -i "s#^basedir=#basedir="$INSTALL_PATH"#g" /etc/init.d/mysqld
sed -i "s#^datadir=#datadir="$DATA_PATH"#g" /etc/init.d/mysqld


chkconfig --add mysqld
chkconfig --level 345 mysqld on


export PATH=/usr/local/mysql/bin:$PATH


ln -s $INSTALL_PATH/bin/mysql /usr/bin


echo "------------------------------------------------------------------------------------------"
echo "------------------------mysql install successful,congratulations!-------------------------"
echo "------------------------------------------------------------------------------------------"

After the script is executed, the login method will be displayed. If you
Insert picture description here
can't find it, you can directly
mysql -uroot -h Your host name or ip address cannot be 127 -pnew_password

If you want to remove -h, change the two socks in my.cnf, and then restart mysql

Guess you like

Origin blog.csdn.net/weixin_44578029/article/details/111595460