1. 程式人生 > >Linux中源碼包安裝MySQL的shell腳本

Linux中源碼包安裝MySQL的shell腳本

login support des ant chown default sets emctl group

#!/bin/bash
#安裝MYSQL
yum -y install ncurses-devel
yum -y install autoconf
tar zxf /cmake- -C /
cd /cmake-

./configure && gmake && gmake install
cd
groupadd mysql
useradd -M -s /sbin/nologin/ mysql -g mysql
tar zxf /mysql- -C /usr/src
cd /usr/src/mysql-

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make && make install
chown -R mysql:mysql /usr/local/mysql
rm -rf /etc/my.cnf
cp support-files/my-default.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
. /etc/profile
cp support-files/mysql.server /usr/local/mysql/bin/mysqld.sh
chmod +x /usr/local/mysql/bin/mysqld.sh
echo "[Unit]" >> /usr/lib/systemd/system/mysqld.service
echo "Description=MYSQL Server" >> /usr/lib/systemd/system/mysqld.service
echo "After=network.target" >> /usr/lib/systemd/system/mysqld.service
echo "[Service]" >> /usr/lib/systemd/system/mysqld.service
echo "User=mysql" >> /usr/lib/systemd/system/mysqld.service
echo "Group=mysql" >> /usr/lib/systemd/system/mysqld.service
echo "Type=forking" >> /usr/lib/systemd/system/mysqld.service
echo "PIDFile=/usr/local/mysql/data/localhost.localdomain.pid" >> /usr/lib/systemd/system/mysqld.service
echo "ExecStart=/usr/local/mysql/bin/mysqld.sh start" >> /usr/lib/systemd/system/mysqld.service
echo "ExecStop=/usr/local/mysql/bin/mysqld.sh stop" >> /usr/lib/systemd/system/mysqld.service
echo "[Install]" >> /usr/lib/systemd/system/mysqld.service
echo "WantedBy=multi-user.target" >> /usr/lib/systemd/system/mysqld.service
systemctl daemon-reload
systemctl start mysqld
systemctl enable mysqld
. /etc/profile

Linux中源碼包安裝MySQL的shell腳本