源码安装
通用二进制包安装
RPM包安装
|
1
2
3
4
5
6
7
|
[root@mysql mysql-5.6.12]# ls
BUILD config.h.cmake extra libmysqld packaging sql-bench unittest
BUILD-CMAKE configure.cmake include libservices plugin sql-common VERSION
client COPYING INSTALL-SOURCE man README storage vio
cmake dbug INSTALL-WIN-SOURCE mysql-test regex strings win
CMakeLists.txt Docs libevent mysys scripts support-files zlib
cmd-line-utils Doxyfile-perfschema libmysql mysys_ssl sql tests
|
源码安装
通用二进制包安装
RPM包安装
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@mysql src]# tar xf cmake-2.8.11.2.tar.gz
[root@mysql src]# cd cmake-2.8.11.2
[root@mysql cmake-2.8.11.2]# ls
bootstrap CTestCustom.cmake.in
ChangeLog.manual CTestCustom.ctest.in
ChangeLog.txt DartConfig.cmake
CMakeCPack.cmake DartLocal.conf.in
CMakeCPackOptions.cmake.in Docs
CMakeGraphVizOptions.cmake doxygen.config
CMakeLists.txt Example
CMakeLogo.gif Modules
cmake_uninstall.cmake.in Readme.txt
CompileFlags.cmake Source
configure Templates
Copyright.txt Tests
CTestConfig.cmake Utilities
[root@mysql cmake-2.8.11.2]# ./bootstrap
[root@mysql cmake-2.8.11.2]# make && make install
|
|
1
2
|
[root@mysql ~]# groupadd -r mysql
[root@mysql ~]# useradd -g mysql -r -s /sbin/nologin mysql
|
|
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
|
[root@mysql ~]# fdisk /dev/sda #创建一个新分区类型为8e
Command (m for help): p
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000a0a2
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1938 5120000 83 Linux
/dev/sda4 1938 2611 5405696 5 Extended
/dev/sda5 1939 2066 1024000 82 Linux swap / Solaris
/dev/sda6 1938 1938 1129+ 83 Linux
/dev/sda7 2066 2327 2099724 8e Linux LVM
[root@mysql ~]# partx -a /dev/sda #让内核重新读取一下分区
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
[root@mysql ~]# fdisk -l #查看新建的分区
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000a0a2
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1938 5120000 83 Linux
/dev/sda4 1938 2611 5405696 5 Extended
/dev/sda5 1939 2066 1024000 82 Linux swap / Solaris
/dev/sda6 1938 1938 1129+ 83 Linux
/dev/sda7 2066 2327 2099724 8e Linux LVM
Partition table entries are not in disk order
[root@mysql ~]# yum install -y lvm2 #安装lvm
[root@mysql ~]# pvcreate /dev/sda7 #创建物理卷
Physical volume "/dev/sda7" successfully created
[root@mysql ~]# vgcreate myvg /dev/sda7 #创建卷组
Volume group "myvg" successfully created
[root@mysql ~]# lvcreate -L 1G -n mydata myvg #创建逻辑卷
Logical volume "mydata" created
[root@mysql ~]# lvs #查看逻辑卷
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
mydata myvg -wi-a---- 1.00g
[root@mysql ~]# mkfs.ext4 /dev/myvg/mydata #格式化
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@mysql ~]# mkdir /mydata #创建挂载目录
[root@mysql ~]# vim /etc/fstab #修改挂载配置文件
#新增一行
/dev/myvg/mydata /mydata ext3 defaults 0 0
[root@mysql ~]# mount -a #挂载
[root@mysql ~]# mount #查看所有挂载
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /data type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/myvg-mydata on /mydata type ext4 (rw)
|
|
1
2
3
4
5
6
7
|
[root@mysql ~]# cd /mydata/
[root@mysql mydata]# mkdir data
[root@mysql mydata]# chown -R mysql.mysql data
[root@mysql mydata]# ll
总用量 20
drwxr-xr-x 2 mysql mysql 4096 7月 18 13:16 data
drwx------ 2 root root 16384 7月 18 13:10 lost+found
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@mysql mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mydata/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL:STRING=bundled \
-DWITH_ZLIB:STRING=bundled \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
|
|
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
|
[root@mysql mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=bundled -DWITH_ZLIB=bundled -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-- Running cmake version 2.8.11.2
-- MySQL 5.6.12
-- Packaging as: mysql-5.6.12-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
CMake Error at cmake/ssl.cmake:164 (FILE):
file STRINGS file "/root/src/mysql-5.6.12/OPENSSL_INCLUDE_DIR-NOTFOUND/openssl/opensslv.h"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:323 (MYSQL_CHECK_SSL)
-- OPENSSL_INCLUDE_DIR = OPENSSL_INCLUDE_DIR-NOTFOUND
-- OPENSSL_LIBRARY = OPENSSL_LIBRARY-NOTFOUND
-- CRYPTO_LIBRARY = CRYPTO_LIBRARY-NOTFOUND
-- OPENSSL_MAJOR_VERSION =
CMake Error at cmake/ssl.cmake:231 (MESSAGE):
Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to
enable SSL support
Call Stack (most recent call first):
CMakeLists.txt:323 (MYSQL_CHECK_SSL)
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:85 (MESSAGE): Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:128 (FIND_CURSES)
cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
|
|
1
|
[root@mysql mysql-5.6.12]# yum install –y openssl openssl-devel ncurses ncurses-devel
|
|
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
|
[root@mysql mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=bundled -DWITH_ZLIB=bundled -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-- Running cmake version 2.8.11.2
-- MySQL 5.6.12
-- Packaging as: mysql-5.6.12-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
CMake Error at cmake/ssl.cmake:164 (FILE):
file STRINGS file "/root/src/mysql-5.6.12/OPENSSL_INCLUDE_DIR-NOTFOUND/openssl/opensslv.h"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:323 (MYSQL_CHECK_SSL)
-- OPENSSL_INCLUDE_DIR = OPENSSL_INCLUDE_DIR-NOTFOUND
-- OPENSSL_LIBRARY = OPENSSL_LIBRARY-NOTFOUND
-- CRYPTO_LIBRARY = CRYPTO_LIBRARY-NOTFOUND
-- OPENSSL_MAJOR_VERSION =
CMake Error at cmake/ssl.cmake:231 (MESSAGE):
Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to
enable SSL support
Call Stack (most recent call first):
CMakeLists.txt:323 (MYSQL_CHECK_SSL)
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:85 (MESSAGE): Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:128 (FIND_CURSES)
cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
|
|
1
2
|
[root@mysql mysql-5.6.12]# rm -rf CMakeCache.txt
[root@mysql mysql-5.6.12]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=bundled -DWITH_ZLIB=bundled -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
|
|
1
|
[root@mysql mysql-5.6.12]# make && make install
|
|
1
2
3
|
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql ----指定残可安装路径(默认的就是/usr/local/mysql)
-DMYSQL_DATADIR=/data/mysql ----mysql的数据文件路径
-DSYSCONFDIR=/etc ----配置文件路径
|
|
1
2
3
|
-DWITH_INNOBASE_STORAGE_ENGINE=1 ----使用INNOBASE存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 ----常应用于日志记录和聚合分析,不支持索引
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 ----黑洞存储引擎
|
|
1
2
3
4
5
|
-DWITHOUT_<ENGINE>_STORAGE_ENGINE=1
示例如下:
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
|
|
1
2
3
4
|
-DWITH_READLINE=1 ----支持批量导入mysql数据
-DWITH_SSL=system ----mysql支持ssl会话,实现基于ssl的数据复
-DWITH_ZLIB=system ----压缩库
-DWITH_LIBWRAP=0 ----是否可以基于WRAP实现访问控制
|
|
1
2
3
4
5
6
7
8
|
-DMYSQL_TCP_PORT=3306 ----默认端口
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock ----默认套接字文件路径
-DENABLED_LOCAL_INFILE=1 ----是否启用LOCAL_INFILE功能
-DEXTRA_CHARSETS=all ----是否支持额外的字符集
-DDEFAULT_CHARSET=utf8 ----默认编码机制
-DDEFAULT_COLLATION=utf8_general_ci ----设定默认语言的排序规则
-DWITH_DEBUG=0 ----DEBUG功能设置
-DENABLE_PROFILING=1 ----性能分析功能是否启用
|
|
1
2
3
4
|
[root@mysql mysql-5.6.12]# cp support-files/mysql.server /etc/init.d/mysqld #复制脚本
[root@mysql mysql-5.6.12]# chmod +x /etc/init.d/mysqld #增加可执行权限
[root@mysql ~]# chkconfig --add mysqld #增加至sysV服务
[root@mysql ~]# chkconfig mysqld on #开机自启动
|
|
1
2
3
4
5
6
7
|
[root@mysql ~]# /usr/local/mysql/scripts/mysql_install_db --datadir=/mydata/data --user=mysql
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
|
|
1
|
[root@mysql data]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mydata/data --user=mysql #mysql初始化
|
|
1
2
3
4
5
6
|
[root@mysql data]# ls #查看生成的文件
ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
[root@mysql data]# cd /usr/local/mysql/
[root@mysql mysql]# ls
bin data include lib my.cnf README share support-files
COPYING docs INSTALL-BINARY man mysql-test scripts sql-bench
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@mysql mysql]# cat my.cnf #查看一下配置文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@mysql mysql]# vim my.cnf
#增加如下内容
binlog-format=ROW
log-bin=master-bin.log
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=1
report-port=3306
port=3306
datadir=/mydata/data
socket=/tmp/mysql.sock
report-host=master.magedu.com
|
|
1
2
|
[root@mysql mysql]# service mysqld start
Starting MySQL... SUCCESS!
|
|
1
2
3
|
root@mysql mysql]# vim /etc/profile.d/mysql.sh
exportPATH=$PATH:/usr/local/mysql/bin
[root@mysql mysql]# source /etc/profile #重新读取环境变量
|
|
1
2
3
|
[root@mysql mysql]# vim /etc/man.config
#新增一行
MANPATH /usr/local/mysql/man
|
|
1
2
3
4
5
|
[root@mysql mysql]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/
[root@mysql mysql]# ldconfig -v
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@mysql mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
"/usr/include/mysql" -> "/usr/local/mysql/include/"
[root@mysql mysql]# cd /usr/include/mysql/
[root@mysql mysql]# ls
big_endian.h m_string.h my_global.h mysql_embed.h plugin_validate_password.h
byte_order_generic.h my_alloc.h my_list.h mysql.h sql_common.h
byte_order_generic_x86_64.h my_attribute.h my_net.h mysql_time.h sql_state.h
byte_order_generic_x86.h my_byteorder.h my_pthread.h mysql_version.h sslopt-case.h
decimal.h my_compiler.h mysql my_sys.h sslopt-longopts.h
errmsg.h my_config.h mysql_com.h my_xml.h sslopt-vars.h
keycache.h my_dbug.h mysql_com_server.h plugin_audit.h typelib.h
little_endian.h my_dir.h mysqld_ername.h plugin_ftparser.h
m_ctype.h my_getopt.h mysqld_error.h plugin.h
|
|
1
2
|
[root@mysql mysql]# netstat -ntulp | grep :3306
tcp 0 0 :::3306 :::* LISTEN 41347/mysqld
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@mysql mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.12-log Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
|
|
1
2
|
[root@web httpd]# rpm -qa | grep lvm
[root@web httpd]# yum install -y lvm2
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@web httpd]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000a0a2
Device Boot Start End Blocks Id System
/dev/sda1* 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda226 1301 10240000 83 Linux
/dev/sda31301 1938 5120000 83 Linux
/dev/sda41938 2611 5405696 5 Extended
/dev/sda51939 2066 1024000 82 Linux swap / Solaris
[root@web httpd]#
|
|
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
|
[root@web ~]# fdisk /dev/sda
/dev/sda72066 2327 2099724 8e Linux LVM #我这里是测试环境就创建了一个2G分区
[root@web ~]# partx -a /dev/sda #告诉内核有关存在和磁盘上的分区的编号
[root@web ~]# pvcreate /dev/sda7 #创建物理卷
Physical volume "/dev/sda7"successfully created
[root@web ~]# vgcreate myvg /dev/sda7 #创建卷组
Volume group "myvg"successfully created
[root@web ~]#
[root@web ~]# lvcreate -n mydata -L 1G myvg #创建一个1G的逻辑卷
Logical volume "mydata"created
[root@web ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
mydata myvg -wi-a---- 1.00g
[root@web ~]#
[root@web ~]# mkfs.ext4 /dev/myvg/mydata #格式化
[root@web ~]# mkdir /mydata #创建挂载目录
[root@web ~]# mount /dev/myvg/mydata /mydata/ #挂载
[root@web ~]# vim /etc/fstab
/dev/myvg/mydata/mydataext4 defaults 0 0 #增加这一行
[root@web ~]# mount –a #测试挂载是否成功
[root@web ~]# mount
/dev/sda2on / typeext4 (rw)
proc on /proctypeproc (rw)
sysfs on /systypesysfs (rw)
devpts on /dev/ptstypedevpts (rw,gid=5,mode=620)
tmpfs on /dev/shmtypetmpfs (rw)
/dev/sda1on /boottypeext4 (rw)
/dev/sda3on /datatypeext4 (rw)
none on /proc/sys/fs/binfmt_misctypebinfmt_misc (rw)
/dev/mapper/myvg-mydataon /mydatatypeext4 (rw)
[root@web ~]#
|
|
1
2
3
|
[root@web ~]# mkdir /mydata/data
[root@web ~]# ls /mydata/
data lost+found
|
|
1
2
3
|
[root@web ~]# groupadd -r mysql
[root@web ~]# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
[root@web ~]# chown -R mysql:mysql /mydata/data
|
|
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
|
[root@web src]# tar -xf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ #-C指定解压目录
[root@web local]# ln -sv mysql-5.6.12-linux-glibc2.5-x86_64/ mysql #创建软链接
`mysql' -> `mysql-5.6.12-linux-glibc2.5-x86_64/'
[root@web local]# cd mysql
[root@web mysql]# ls
bin data include lib mysql-testscripts sql-bench
COPYING docs INSTALL-BINARY manREADME share support-files
[root@web mysql]#
[root@web mysql]# chown -R mysql:mysql . #更改属主属组
[root@web mysql]# ll
total 76
drwxr-xr-x 2 mysql mysql 4096 Jun 29 21:12 bin
-rw-r--r-- 1 mysql mysql 17987 May 21 23:18 COPYING
drwxr-xr-x 3 mysql mysql 4096 Jun 29 21:12 data
drwxr-xr-x 2 mysql mysql 4096 Jun 29 21:12 docs
drwxr-xr-x 3 mysql mysql 4096 Jun 29 21:12 include
-rw-r--r-- 1 mysql mysql 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 Jun 29 21:12 lib
drwxr-xr-x 4 mysql mysql 4096 Jun 29 21:12 man
drwxr-xr-x 10 mysql mysql 4096 Jun 29 21:12 mysql-test
-rw-r--r-- 1 mysql mysql 2496 May 21 23:18 README
drwxr-xr-x 2 mysql mysql 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 mysql mysql 4096 Jun 29 21:12 share
drwxr-xr-x 4 mysql mysql 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 mysql mysql 4096 Jun 29 21:12 support-files
|
|
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
|
[root@web mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data #执行mysql 初始化的data存放位置的准备
Installing MySQL system tables..../bin/mysqld: error whileloading shared libraries: libaio.so.1: cannot openshared object file: No such fileor directory
#初始化时报错说缺少libaio.so我们安装一下
[root@web mysql]# yum install libaio
[root@web mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data #再次执行mysql 初始化的data存放位置的准备
To start mysqld at boot timeyou have to copy
support-files/mysql.server to the right place foryour system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To doso, start the server, thenissue the following commands:
./bin/mysqladmin-u root password 'new-password'
./bin/mysqladmin-u root -h web.test.com password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
whichwill also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended forproduction servers.
See the manual formoreinstructions.
You can start the MySQL daemon with:
cd. ; ./bin/mysqld_safe&
You can testthe MySQL daemon with mysql-test-run.pl
cdmysql-test; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbugscript!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licensesat http://shop.mysql.com
WARNING: Found existing config file./my.cnf on the system.
Because this filemight be inuse, it was not replaced,
but was used inbootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config filewas created as ./my-new.cnf,
please compare it with your fileand take the changes you need.
WARNING: Default config file/etc/my.cnf exists on the system
This filewill be readby default by the MySQL server
If you donot want to use this, either remove it, or use the
--defaults-fileargument to mysqld_safe when starting the server
[root@web mysql]#
[root@web mysql]# ls /mydata/data/ #查看 data 目录有文件说明初始化成功
ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@web mysql]# cd /usr/local/mysql/
[root@web mysql]# chown root /usr/local/mysql/* -R
[root@web mysql]# ll
total 84
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 bin
-rw-r--r-- 1 root mysql 17987 May 21 23:18 COPYING
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 data
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 include
-rw-r--r-- 1 root mysql 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root mysql 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root mysql 4096 Jun 29 21:12 mysql-test
-rw-r--r-- 1 root mysql 2496 May 21 23:18 README
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root mysql 4096 Jun 29 21:12 share
drwxr-xr-x 4 root mysql 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 support-files
[root@web mysql]#
|
|
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
|
[root@web mysql]# ll
total 84
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 bin
-rw-r--r-- 1 root mysql 17987 May 21 23:18 COPYING
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 data
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 include
-rw-r--r-- 1 root mysql 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root mysql 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root mysql 4096 Jun 29 21:12 mysql-test
-rw-r--r-- 1 root mysql 2496 May 21 23:18 README
drwxr-xr-x 2 root mysql 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root mysql 4096 Jun 29 21:12 share
drwxr-xr-x 4 root mysql 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root mysql 4096 Jun 29 21:12 support-files
[root@web mysql]#
[root@web mysql]# cat my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@web mysql]#
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@web mysql]# vim my.cnf
添加内容是:
binlog-format=ROW
log-bin=master-bin.log
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=1
report-port=3306
port=3306
datadir=/mydata/data
socket=/tmp/mysql.sock
report-host=master.test.com
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@web mysql]# cp support-files/mysql.server /etc/init.d/mysqld #复制sysv脚本
[root@web mysql]# chkconfig --add mysqld
[root@web mysql]# chkconfig mysqld on #开机自启动
[root@web mysql]# chkconfig mysqld --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web mysql]# service mysqld start
Starting MySQL.... SUCCESS!
[root@web mysql]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Programname
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 990/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1066/master
tcp 0 0 :::80 :::* LISTEN 37120/httpd
tcp 0 0 :::22 :::* LISTEN 990/sshd
tcp 0 0 ::1:25 :::* LISTEN 1066/master
tcp 0 0 :::3306 :::* LISTEN 37924/mysqld#mysql启动成功
udp 0 0 0.0.0.0:68 0.0.0.0:* 890/dhclient
|
|
1
2
|
[root@web mysql]# vim /etc/man.config
MANPATH /usr/local/mysql/man#增加这一行
|
|
1
2
3
|
[root@web mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql #输出mysql的头文件至系统头文件
`/usr/include/mysql' -> `/usr/local/mysql/include/'
[root@web mysql]# cd /usr/include/mysql/
|
|
1
2
3
4
5
6
7
8
9
10
|
[root@web mysql]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
#直接新建编辑/etc/ld.so.conf.d/mysql.conf文件,把mysql的库文件路径添加进去就可以了
[root@web mysql]# ldconfig –v# 让系统重新读取库文件
/usr/local/mysql/lib:
libtcmalloc_minimal.so.0 -> libtcmalloc_minimal.so (changed)
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
/usr/lib64/mysql:
libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0
|
|
1
2
3
|
[root@web mysql]# vim /etc/profile.d/mysql.sh #添加环境变量(与添加httpd是一样的)
exportPATH=$PATH:/usr/local/mysql/bin
[root@web mysql]# source /etc/profile #重新读取一下环境变量
|
|
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
|
[root@web mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.6.12-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/orits affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/orits
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;'or '\h'forhelp. Type '\c'to clearthe current input statement.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test|
+--------------------+
4 rows inset(0.02 sec)
mysql>
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.03 sec)
|
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29313086/viewspace-1749391/ ,如需转载,请注明出处,否则将追究法律责任。