#!/bin/bash #-------------------install mysql 5.6.27 :: begin------------------------ mysql -V &>/dev/null if [ $? -eq 0 ];then mysql -V echo "mysql is exist" else cd /app/service/tools tar -zxvf mysql-5.6.27.tar.gz cd mysql-5.6.27 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make && make install #创建用户和用户组 groupadd mysql && useradd -g mysql mysql && echo "useradd mysql finish..." #创建目录并分配权限 mkdir /usr/local/mysql &>/dev/null chown -R mysql:mysql /usr/local/mysql #进入安装目录执行脚本,启动服务 cd /usr/local/mysql scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql cp support-files/mysql.server /etc/init.d/mysql rm -rf /etc/my.cnf chkconfig mysql on service mysql start #设置PATH,直接调用mysql ln -s /usr/local/mysql/bin/mysql /usr/bin/ fi
时间: 2024-10-22 13:48:17