标签:一键安装mysql
#!/bin/sh
#一键安装单实例mysql
#xiaogao 20190921
#创建相关mysql用户
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
tail -1 /etc/passwd
#安装mysql依赖库
yum -y install ncurses-devel
#开启安装mysql,记得先上传安装包到/home/lvnian/tools/
cd /home/lvnian/tools/
tar zxf mysql-5.1.72.tar.gz
cd mysql-5.1.72
./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
#--with-plugin-PLUGIN \
make && make install
echo $?
#制作软连接:
ln -s /application/mysql5.1.72 /application/mysql
#创建msyql数据库文件
cd /home/lvnian/tools/mysql-5.1.72/support-files/
ls my*.cnf -l
/bin/cp my-small.cnf /etc/my.cnf
mkdir /application/mysql/data -p
chown -R mysql.mysql /application/mysql/data/
#初始化数据库
/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
#启动mysql数据库
#/application/mysql/bin/mysqld_safe &
#启动方法2
echo "-----------启动方法mysql 2---------------"
cp /home/lvnian/tools/mysql-5.1.72/support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
/etc/init.d/mysqld restart
sleep 5
netstat -lnt|grep 3306
lsof -i :3306
#设置mysql命令全局使用路径
echo ‘PATH=$PATH:/application/mysql/bin‘ >> /etc/profile
source /etc/profile
which mysql
#设置开机自启动mysql数据库
chkconfig --add mysqld
chkconfig mysqld on
chkconfig --list mysqld
#进入数据库:
mysql
quit;
####单实例mysql安装完毕
#########################################################################################################################
#修改密码
mysqladmin -uroot password ‘lvnian‘
本文出自 “技术改变命运” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1696817
标签:一键安装mysql
原文地址:http://lvnian.blog.51cto.com/7155281/1696817