Linux中源码包安装MySQL的shell脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux中源码包安装MySQL的shell脚本相关的知识,希望对你有一定的参考价值。
#!/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脚本的主要内容,如果未能解决你的问题,请参考以下文章