安装Mysql 5.7

Mysql 下载地址:

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

安装Mysql 5.7_第1张图片
image.png

安装Mysql 5.7_第2张图片
image.png

安装脚本:
#!/bin/bash
cd `dirname $0`
baseDir=`pwd`
mysqlInstallDir=/usr/local/mysql5.7
groupadd mysql
useradd -g mysql mysql
tar -xzvf mysql-5.7.24-el7-x86_64.tar.gz
mv mysql-5.7.24-el7-x86_64/ mysql5.7
mv mysql5.7 /usr/local/

cd /usr/local
chown -R mysql mysql5.7
chgrp -R mysql mysql5.7
cd mysql5.7

mkdir data

chown -R mysql:mysql data
rm -rf /etc/my.cnf
mv $baseDir/my.cnf /etc/my.cnf

$mysqlInstallDir/bin/mysql_install_db --user=mysql --basedir=$mysqlInstallDir --datadir=$mysqlInstallDir/data
cp $mysqlInstallDir/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld restart
echo "设置Mysql开机启动" 
chkconfig --level 35 mysqld on
chkconfig --list mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
service mysqld status

echo 'export PATH=$PATH:/usr/local/mysql5.7/bin' >> /etc/profile
source /etc/profile
echo "Mysql 安装完成,root登录密码如下:"
cat /root/.mysql_secret 
my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
skip-name-resolve
# #设置3306端口
port = 3306 
# # 设置mysql的安装目录
basedir=/usr/local/mysql5.7
# # 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql5.7/data
# # 允许最大连接数
max_connections=200
# # 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# # 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB 
lower_case_table_names=1
max_allowed_packet=16M

你可能感兴趣的:(安装Mysql 5.7)