码迷,mamicode.com
首页 > 数据库 > 详细

Linux中源码包安装MySQL的shell脚本

时间:2018-10-09 17:05:44      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:figure   exec   general   ext   ecs   target   emctl   localhost   chm   

#!/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脚本

标签:figure   exec   general   ext   ecs   target   emctl   localhost   chm   

原文地址:http://blog.51cto.com/14010760/2296268

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!