-
Notifications
You must be signed in to change notification settings - Fork 0
/
mariadb-install.sh
79 lines (68 loc) · 2.24 KB
/
mariadb-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#mariadb安装脚本版本10.0
MariadbYum(){
cat > /etc/yum.repos.d/MariaDB.repo <<EOF
# MariaDB 10.0 CentOS repository list - created 2015-02-06 05:28 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
}
MariadbInstall(){
sudo -i
yum install MariaDB-server MariaDB-client
systemctl is-enable mariadb
systemctl start mariadb
#'/usr/bin/mysqladmin' -u root password 'new-password'
#'/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
#'/usr/bin/mysql_secure_installation'
cp /etc/my.cnf{,.original}
cp /etc/my.cnf.d/server.cnf{,.original}
cp /etc/my.cnf.d/client.cnf{,.original}
sed -i '10iskip-name-resolve' /etc/my.cnf.d/server.cnf
sed -i '11imax_connections=8192' /etc/my.cnf.d/server.cnf
sed -i '12idefault-storage-engine=INNODB' /etc/my.cnf.d/server.cnf
sed -i '13iwait_timeout=30' /etc/my.cnf.d/server.cnf
sed -i '14iinteractive_timeout=30' /etc/my.cnf.d/server.cnf
sed -i '15icharacter-set-server=utf8' /etc/my.cnf.d/server.cnf
sed -i '16icollation_server=utf8_general_ci' /etc/my.cnf.d/server.cnf
sed -i "17iinit_connect='SET NAMES utf8'" /etc/my.cnf.d/server.cnf
sed -i '18iexplicit_defaults_for_timestamp=true' /etc/my.cnf.d/server.cnf
sed -i '5icharacter_set_client=utf8' /etc/my.cnf.d/client.cnf
}
FirewallMariadb(){
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
service iptables save
}
deploy(){
clear
echo "################MaridbInstall脚本工具################"
echo "# #"
echo "# 0.自动配置yum源并安装mariadb #"
echo "# 1.安装Maridb-server MariaDB-client #"
echo "# 2.如果防火墙开启则开通3306端口 #"
echo "# 3.退出 #"
echo "#####################################################"
read -p "请输入选项:" ID
case $ID in
0)
MariadbYum&&MariadbInstall
;;
1)
MariadbInstall
;;
2)
FirewallMariadb
;;
3)
exit 0
;;
*)
echo "输入不合法,请重新输入检测输入信息" && deploy
;;
esac
}
deploy