rhel7.0 安装mysql5.7

#rhel7.0 install mysql5.7 


yum install libaio -y

groupadd mysql

useradd -g mysql -s /sbin/nologin mysql 


tar xzvf mysql-5.7.8-rc-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.8-rc-linux-glibc2.5-x86_64 /usr/local/mysql

rm -rvf /etc/my.cnf

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

chown -R mysql.mysql /usr/local/mysql/


egrep -v '^#|^$' /etc/my.cnf

[mysqld]

explicit_defaults_for_timestamp=true

log-error=error.log

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  



#初始化mysql

/usr/local/mysql/bin/mysqld   --initialize --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql


#配置环境变量


echo "export PATH=/usr/local/mysql/bin:$PATH" >>/etc/profile

source /etc/profile

mysql --version




#启动mysql

/usr/local/mysql/bin/mysqld_safe --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ &


#关闭mysql

mysqladmin shutdown




[root@rhel7 ~]# cat start.sh 

#!/bin/bash 

/usr/local/mysql/bin/mysqld_safe --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ &


[root@rhel7 ~]# chmod 755 start.sh 


[root@rhel7 ~]# ./start.sh 



#关闭

[root@rhel7 ~]# cat stop.sh 

#!/bin/bash

mysqladmin shutdown



[root@rhel7 ~]# chmod 755 stop.sh


[root@rhel7 ~]# ./stop.sh 














你可能感兴趣的:(mysql)