-
Notifications
You must be signed in to change notification settings - Fork 9
/
install-mysql-sh
110 lines (85 loc) · 3.46 KB
/
install-mysql-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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
MYSQL_VERSION="5.5.29-rel29.4"
echo "to root path"
cd /home/software
echo "create user"
sudo groupadd mysql
sudo useradd -m mysql -g mysql
echo "create directory"
sudo mkdir -p /etc/mysql
sudo mkdir -p /var/mysql
sudo mkdir -p /var/mysql/tmp
sudo mkdir -p /var/mysql/data
sudo mkdir -p /var/mysql/logs
sudo chown -R mysql:mysql /var/mysql
sudo chown -R mysql:mysql /etc/mysql
echo "install binary package"
cd mysql
rm -fr Percona-Server-${MYSQL_VERSION}/*
INSTALL_PATH="/usr/local/mysql"
DATA_PATH="/var/mysql/data"
sudo apt-get install -f bison
echo "install Percona-Server"
tar -zxf Percona-Server-${MYSQL_VERSION}.tar.gz
cd Percona-Server-${MYSQL_VERSION}
echo "install Percona-Server"
CC=gcc CFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -O3" CXX=g++ CXXFLAGS="-DBIG_JOINS=1 -DHAVE_DLOPEN=1 -felide-constructors -fno-rtti -O3"
cmake . \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DSYSCONFDIR:PATH=${INSTALL_PATH} \
-DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} \
-DENABLED_PROFILING:BOOL=ON \
-DENABLE_DEBUG_SYNC:BOOL=OFF \
-DMYSQL_DATADIR:PATH=${DATA_PATH} \
-DMYSQL_MAINTAINER_MODE:BOOL=OFF \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \
-DWITH_BIG_TABLES:BOOL=ON \
-DWITH_FAST_MUTEXES:BOOL=ON \
-DENABLE-PROFILING:BOOL=ON \
-DWITH_SSL:STRING=bundled \
-DWITH_UNIT_TESTS:BOOL=OFF \
-DWITH_ZLIB:STRING=bundled \
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \
-DWITH_SERVER_SUFFIX=hxsw \
-DWITH_PLUGINS=heap,csv,partition,innodb_plugin,myisam \
-DEFAULT_COLLATION=utf8_general_ci \
-DEFAULT_CHARSET=utf8 \
-DENABLED_ASSEMBLER:BOOL=ON \
-DENABLED_LOCAL_INFILE:BOOL=ON \
-DENABLED_THREAD_SAFE_CLIENT:BOOL=ON \
-DENABLED_EMBEDDED_SERVER:BOOL=OFF \
-DWITH_CLIENT_LDFLAGS:STRING=all-static \
-DINSTALL_LAYOUT:STRING=STANDALONE \
-DCOMMUNITY_BUILD:BOOL=ON;
echo "install Percona-Server"
make
echo "install Percona-Server"
sudo make install
echo "install HandlerSocket-Plugin-for-MySQL"
cd storage/HandlerSocket-Plugin-for-MySQL/
./autogen.sh
./configure --with-mysql-source=/home/software/mysql/Percona-Server-${MYSQL_VERSION} --with-mysql-bindir=${INSTALL_PATH}/bin/ --with-mysql-plugindir=${INSTALL_PATH}/lib/mysql/plugin
make
sudo make install
sudo chown -R mysql:mysql /usr/local/mysql
echo "===================================================="
echo "config Percona Server"
echo "===================================================="
cd /home/software/mysql/Percona-Server-${MYSQL_VERSION}/scripts
sudo ./mysql_install_db --basedir=${INSTALL_PATH} --datadir=${DATA_PATH} --user=mysql
echo "install file to /etc/init.d"
cd /home/software
sudo cp mysql/mysql /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
echo "install my.cnf to /etc/mysql"
sudo cp mysql/my.cnf /etc/mysql/my.cnf
echo "config services"
sudo update-rc.d mysql defaults
sudo echo "/usr/local/mysql/lib" >> /etc/ld.so.conf.d/mysql.conf
sudo ldconfig
sudo ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
sudo ln -s /usr/local/mysql/bin/mysqldump /usr/local/bin/mysqldump
sudo service mysql start
sudo ${INSTALL_PATH}/bin/mysqladmin -u root password 'mysql@pwd'
sudo ${INSTALL_PATH}/bin/mysqladmin -u root -h 127.0.1.1 password 'mysql@pwd'
echo "done"