【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装
源码编译安装的更多内容:http://blog.itpub.net/26736162/viewspace-2144212/
地址:https://dev.mysql.com/downloads/mysql/
说明:这里有两个包,在5.7以后,必须要有boost这个包
groupadd mysql useradd -r -g mysql mysql |
其中-r表示用户是系统用户,不可登录系统。
[root@LHRDB ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rootlhr-Vol00 9.9G 4.6G 4.9G 49% / tmpfs 2.0G 76K 2.0G 1% /dev/shm /dev/sda1 194M 35M 150M 19% /boot /dev/mapper/vg_rootlhr-Vol01 3.0G 1.8G 1.1G 64% /tmp /dev/mapper/vg_rootlhr-Vol03 3.0G 69M 2.8G 3% /home /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57 5.0G 2.7G 2.0G 58% /var/lib/mysql57 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56 2.0G 1.4G 575M 70% /usr/local/mysql56 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55 2.0G 848M 1.1G 45% /usr/local/mysql55 .host:/ 331G 273G 58G 83% /mnt/hgfs /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1 /dev/sr0 3.6G 3.6G 0 100% /media/lhr/cdrom [root@LHRDB ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_mysqlsoft 1 3 0 wz--n- 10.00g 1020.00m vg_rootlhr 2 4 0 wz--n- 19.80g 1.80g [root@LHRDB ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_rootlhr lvm2 a-- 10.00g 0 /dev/sda3 vg_rootlhr lvm2 a-- 9.80g 1.80g /dev/sdb1 vg_mysqlsoft lvm2 a-- 10.00g 1020.00m /dev/sdb10 lvm2 a-- 10.00g 10.00g /dev/sdb11 lvm2 a-- 9.99g 9.99g /dev/sdb2 lvm2 a-- 10.00g 10.00g /dev/sdb3 lvm2 a-- 10.00g 10.00g /dev/sdb5 lvm2 a-- 10.00g 10.00g /dev/sdb6 lvm2 a-- 10.00g 10.00g /dev/sdb7 lvm2 a-- 10.00g 10.00g /dev/sdb8 lvm2 a-- 10.00g 10.00g /dev/sdb9 lvm2 a-- 10.00g 10.00g [root@LHRDB ~]# vgextend vg_mysqlsoft /dev/sdb2 Volume group "vg_mysqlsoft" successfully extended [root@LHRDB ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_mysqlsoft 2 3 0 wz--n- 19.99g 10.99g vg_rootlhr 2 4 0 wz--n- 19.80g 1.80g [root@LHRDB ~]# lvcreate -n lv_mysqlsoft_57sc -L 10G vg_mysqlsoft Logical volume "lv_mysqlsoft_57sc" created [root@LHRDB ~]# mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_57sc mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280 40 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@LHRDB ~]# mkdir /usr/local/mysql57sc [root@LHRDB ~]# chown mysql.mysql /usr/local/mysql57sc [root@LHRDB ~]# mount /dev/vg_mysqlsoft/lv_mysqlsoft_57sc /usr/local/mysql57sc/ [root@LHRDB ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rootlhr-Vol00 9.9G 4.6G 4.8G 49% / tmpfs 2.0G 76K 2.0G 1% /dev/shm /dev/sda1 194M 35M 150M 19% /boot /dev/mapper/vg_rootlhr-Vol01 3.0G 1.8G 1.1G 64% /tmp /dev/mapper/vg_rootlhr-Vol03 3.0G 69M 2.8G 3% /home /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57 5.0G 2.7G 2.0G 58% /var/lib/mysql57 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56 2.0G 1.4G 575M 70% /usr/local/mysql56 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55 2.0G 848M 1.1G 45% /usr/local/mysql55 .host:/ 331G 273G 58G 83% /mnt/hgfs /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1 /dev/sr0 3.6G 3.6G 0 100% /media/lhr/cdrom /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc 9.9G 138M 9.6G 1% /usr/local/mysql57sc [root@LHRDB ~]# more /etc/fstab # # /etc/fstab # Created by anaconda on Sat Jan 14 18:56:24 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_rootlhr-Vol00 / ext4 defaults 1 1 UUID=fccf51c1-2d2f-4152-baac-99ead8cfbc1a /boot ext4 defaults 1 2 /dev/mapper/vg_rootlhr-Vol01 /tmp ext4 defaults 1 2 /dev/mapper/vg_rootlhr-Vol02 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults,size=2G 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/vg_rootlhr/Vol03 /home ext4 defaults 0 0 /dev/vg_mysqlsoft/lv_mysqlsoft_57 /var/lib/mysql57 ext4 defaults 0 0 /dev/vg_mysqlsoft/lv_mysqlsoft_56 /usr/local/mysql56 ext4 defaults 0 0 /dev/vg_mysqlsoft/lv_mysqlsoft_55 /usr/local/mysql55 ext4 defaults 0 0 /dev/sr0 /media/lhr/cdrom iso9660 defaults,ro,loop 0 0 /dev/vg_mysqlsoft/lv_mysqlsoft_57sc /usr/local/mysql57sc ext4 defaults 0 0
|
[root@LHRDB ~]# mkdir -p /tmp/mysql5.7sc |
[root@LHRDB ~]# cd /tmp/mysql5.7sc [root@LHRDB mysql5.7sc]# ll total 98136 -rw-r--r-- 1 root root 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz -rw-r--r-- 1 root root 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz [root@LHRDB mysql5.7sc]# tar -zxf /tmp/mysql5.7sc/mysql-5.7.19.tar.gz -C /usr/local/mysql57sc/ [root@LHRDB mysql5.7sc]# tar -zxf /tmp/mysql5.7sc/mysql-boost-5.7.19.tar.gz -C /usr/local/mysql57sc/ [root@LHRDB mysql5.7sc]# ll total 98140 drwxr-xr-x 36 7161 31415 4096 Jun 22 22:24 mysql-5.7.19 -rw-r--r-- 1 root root 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz -rw-r--r-- 1 root root 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz [root@LHRDB mysql5.7sc]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rootlhr-Vol00 9.9G 4.7G 4.8G 50% / tmpfs 2.0G 76K 2.0G 1% /dev/shm /dev/sda1 194M 35M 150M 19% /boot /dev/mapper/vg_rootlhr-Vol01 3.0G 1.6G 1.3G 56% /tmp /dev/mapper/vg_rootlhr-Vol03 3.0G 69M 2.8G 3% /home /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57 5.0G 2.7G 2.0G 58% /var/lib/mysql57 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56 2.0G 1.4G 575M 70% /usr/local/mysql56 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55 2.0G 848M 1.1G 45% /usr/local/mysql55 .host:/ 331G 273G 58G 83% /mnt/hgfs /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1 /dev/sr0 3.6G 3.6G 0 100% /media/lhr/cdrom /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc 9.9G 683M 9.4G 7% /usr/local/mysql57sc |
修改目录的权限:
[root@LHRDB local]# cd /usr/local/mysql57sc [root@LHRDB mysql57sc]# mv mysql-5.7.19 mysql57 [root@LHRDB mysql57sc]# mkdir ./mysql57/data [root@LHRDB mysql57sc]# mkdir ./mysql57/log [root@LHRDB mysql57sc]# chown -R mysql.mysql .
|
mkdir -p /media/lhr/cdrom mount /dev/sr0 /media/lhr/cdrom/
#设置开机自动挂载系统镜像文件 vi /etc/fstab 添加以下内容 /dev/sr0 /media/lhr/cdrom iso9660 defaults,ro,loop 0 0
cd /etc/yum.repos.d/ cp rhel-media.repo rhel-media.repo.bk vi /etc/yum.repos.d/rhel-media.repo [rhel-media] name=Red Hat Enterprise Linux 6.5 baseurl=file:///media/lhr/cdrom enabled=1 gpgcheck=1 gpgkey=file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release |
[root@LHRDB ~]# mkdir -p /media/lhr/cdrom [root@LHRDB ~]# mount /dev/sr0 /media/lhr/cdrom/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@LHRDB ~]# cd /etc/yum.repos.d/ [root@LHRDB yum.repos.d]# cp rhel-media.repo rhel-media.repo.bk [root@LHRDB yum.repos.d]# more /etc/yum.repos.d/rhel-media.repo [rhel-media] name=Red Hat Enterprise Linux 6.5 baseurl=file:///media/lhr/cdrom enabled=1 gpgcheck=1 gpgkey=file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release
|
yum install -y cmake make gcc gcc-c++ ncurses-devel |
[root@LHRDB yum.repos.d]# yum install -y cmake make gcc gcc-c++ ncurses-devel Loaded plugins: product-id, refresh-packagekit, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. rhel-media | 3.9 kB 00:00 ... Setting up Install Process Package 1:make-3.81-20.el6.x86_64 already installed and latest version Package gcc-4.4.7-4.el6.x86_64 already installed and latest version Package gcc-c++-4.4.7-4.el6.x86_64 already installed and latest version Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package cmake.x86_64 0:2.6.4-5.el6 will be installed --> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================== Installing: cmake x86_64 2.6.4-5.el6 rhel-media 5.1 M
Transaction Summary ================================================================================================================================================================================================================== Install 1 Package(s)
Total download size: 5.1 M Installed size: 17 M Downloading Packages: warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Retrieving key from file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release Importing GPG key 0xFD431D51: Userid: "Red Hat, Inc. (release key 2) From : /media/lhr/cdrom/RPM-GPG-KEY-redhat-release Importing GPG key 0x2FA658E0: Userid: "Red Hat, Inc. (auxiliary key) From : /media/lhr/cdrom/RPM-GPG-KEY-redhat-release Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : cmake-2.6.4-5.el6.x86_64 1/1 Verifying : cmake-2.6.4-5.el6.x86_64 1/1
Installed: cmake.x86_64 0:2.6.4-5.el6
Complete!
|
注意:这里的cmake最低需要2.8.2版本的,不然会报错,先接着往下做吧。
[root@LHRDB mysql-5.7.19]# cmake -version cmake version 2.6-patch 4 [root@LHRDB mysql-5.7.19]# pwd /tmp/mysql5.7sc/mysql-5.7.19 [root@LHRDB mysql-5.7.19]# ll total 332 drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 boost drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 BUILD drwxr-xr-x 6 7161 31415 4096 Jun 22 22:24 client drwxr-xr-x 4 7161 31415 4096 Jun 22 22:24 cmake -rw-r--r-- 1 7161 31415 26727 Jun 22 22:13 CMakeLists.txt drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 cmd-line-utils -rw-r--r-- 1 7161 31415 13832 Jun 22 22:13 config.h.cmake -rw-r--r-- 1 7161 31415 33704 Jun 22 22:13 configure.cmake -rw-r--r-- 1 7161 31415 17987 Jun 22 22:13 COPYING drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 dbug drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 Docs -rw-r--r-- 1 7161 31415 66241 Jun 22 22:13 Doxyfile-perfschema drwxr-xr-x 6 7161 31415 4096 Jun 22 22:24 extra drwxr-xr-x 5 7161 31415 4096 Jun 22 22:24 include -rw-r--r-- 1 7161 31415 333 Jun 22 22:13 INSTALL drwxr-xr-x 5 7161 31415 4096 Jun 22 22:24 libbinlogevents drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 libbinlogstandalone drwxr-xr-x 7 7161 31415 4096 Jun 22 22:24 libevent drwxr-xr-x 4 7161 31415 4096 Jun 22 22:24 libmysql drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 libmysqld drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 libservices drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 man drwxr-xr-x 10 7161 31415 4096 Jun 22 22:24 mysql-test drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 mysys drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 mysys_ssl drwxr-xr-x 10 7161 31415 4096 Jun 22 22:24 packaging drwxr-xr-x 18 7161 31415 4096 Jun 22 22:24 plugin drwxr-xr-x 4 7161 31415 4096 Jun 22 22:24 rapid -rw-r--r-- 1 7161 31415 2478 Jun 22 22:13 README drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 regex drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 scripts drwxr-xr-x 7 7161 31415 20480 Jun 22 22:24 sql drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 sql-common drwxr-xr-x 14 7161 31415 4096 Jun 22 22:24 storage drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 strings drwxr-xr-x 4 7161 31415 4096 Jun 22 22:24 support-files drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 testclients drwxr-xr-x 5 7161 31415 4096 Jun 22 22:24 unittest -rw-r--r-- 1 7161 31415 88 Jun 22 22:13 VERSION drwxr-xr-x 3 7161 31415 4096 Jun 22 22:24 vio drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 win drwxr-xr-x 2 7161 31415 4096 Jun 22 22:24 zlib [root@LHRDB mysql-5.7.19]# cmake / > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 / > -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data / > -DMYSQL_USER=mysql / > -DWITH_INNOBASE_STORAGE_ENGINE=1 / > -DWITH_ARCHIVE_STORAGE_ENGINE=1 / > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 / > -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 / > -DWITH_READLINE=1 / > -DDOWNLOAD_BOOST=1 / > -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/ CMake Error at CMakeLists.txt:21 (CMAKE_MINIMUM_REQUIRED): CMake 2.8.2 or higher is required. You are running version 2.6.4
-- Configuring incomplete, errors occurred!
|
cmake每个参数的介绍参考:http://blog.itpub.net/26736162/viewspace-2144212/
下载高版本cmake,http://www.cmake.org/cmake/resources/software.html,解压缩cmake-3.9.1.tar.gz,解压后执行“./bootstrap && make && make install”,如下:
[root@LHRDB ~]# cd /tmp/mysql5.7sc/ [root@LHRDB mysql5.7sc]# ll total 105664 -rw-r--r-- 1 root root 7702497 Aug 28 10:20 cmake-3.9.1.tar.gz drwxr-xr-x 37 7161 31415 4096 Aug 28 10:38 mysql-5.7.19 -rw-r--r-- 1 root root 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz -rw-r--r-- 1 root root 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz [root@LHRDB mysql5.7sc]# tar -zxf cmake-3.9.1.tar.gz [root@LHRDB mysql5.7sc]# ll total 105668 drwxr-xr-x 11 root root 4096 Aug 28 10:42 cmake-3.9.1 -rw-r--r-- 1 root root 7702497 Aug 28 10:20 cmake-3.9.1.tar.gz drwxr-xr-x 37 7161 31415 4096 Aug 28 10:38 mysql-5.7.19 -rw-r--r-- 1 root root 51686763 Aug 28 09:50 mysql-5.7.19.tar.gz -rw-r--r-- 1 root root 48799895 Aug 28 09:50 mysql-boost-5.7.19.tar.gz [root@LHRDB mysql5.7sc]# cd cmake-3.9.1 [root@LHRDB cmake-3.9.1]# ll total 284 drwxr-xr-x 4 502 games 4096 Aug 10 21:47 Auxiliary -rwxr-xr-x 1 502 games 48336 Aug 10 21:36 bootstrap -rw-r--r-- 1 502 games 9706 Aug 10 21:36 CMakeCPack.cmake -rw-r--r-- 1 502 games 12897 Aug 10 21:36 CMakeCPackOptions.cmake.in -rw-r--r-- 1 502 games 153 Aug 10 21:36 CMakeGraphVizOptions.cmake -rw-r--r-- 1 502 games 31721 Aug 10 21:36 CMakeLists.txt -rw-r--r-- 1 502 games 4481 Aug 10 21:36 CMakeLogo.gif -rw-r--r-- 1 502 games 790 Aug 10 21:36 cmake_uninstall.cmake.in -rw-r--r-- 1 502 games 3322 Aug 10 21:36 CompileFlags.cmake -rwxr-xr-x 1 502 games 99 Aug 10 21:36 configure -rw-r--r-- 1 502 games 1851 Aug 10 21:36 CONTRIBUTING.rst -rw-r--r-- 1 502 games 4999 Aug 10 21:36 Copyright.txt -rw-r--r-- 1 502 games 440 Aug 10 21:36 CTestConfig.cmake -rw-r--r-- 1 502 games 6213 Aug 10 21:36 CTestCustom.cmake.in -rw-r--r-- 1 502 games 374 Aug 10 21:36 DartConfig.cmake -rw-r--r-- 1 502 games 28046 Aug 10 21:36 doxygen.config drwxr-xr-x 18 502 games 4096 Aug 10 21:47 Help drwxr-xr-x 2 502 games 4096 Aug 10 21:47 Licenses drwxr-xr-x 12 502 games 20480 Aug 10 21:47 Modules drwxr-xr-x 3 502 games 4096 Aug 10 21:47 Packaging -rw-r--r-- 1 502 games 3016 Aug 10 21:36 README.rst drwxr-xr-x 11 502 games 36864 Aug 10 21:47 Source drwxr-xr-x 4 502 games 4096 Aug 10 21:47 Templates drwxr-xr-x 240 502 games 12288 Aug 10 21:47 Tests drwxr-xr-x 21 502 games 4096 Aug 10 21:47 Utilities [root@LHRDB cmake-3.9.1]# [root@LHRDB cmake-3.9.1]# ./bootstrap && make && make install --------------------------------------------- CMake 3.9.1, Copyright 2000-2017 Kitware, Inc. and Contributors Found GNU toolchain C compiler on this system is: gcc -std=gnu99 C++ compiler on this system is: g++ -std=gnu++0x Makefile processor on this system is: gmake g++ is GNU compiler g++ has setenv g++ has unsetenv g++ does not have environ in stdlib.h g++ has stl wstring g++ has --------------------------------------------- g++ -std=gnu++0x -I/tmp/mysql5.7sc/cmake-3.9.1/Bootstrap.cmk -I/tmp/mysql5.7sc/cmake-3.9.1/Source -I/tmp/mysql5.7sc/cmake-3.9.1/Source/LexerParser -I/tmp/mysql5.7sc/cmake-3.9.1/Utilities -c /tmp/mysql5.7sc/cmake-3.9.1/Source/cmAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o g++ -std=gnu++0x -I/tmp/mysql5.7sc/cmake-3.9.1/Bootstrap.cmk -I/tmp/mysql5.7sc/cmake-3.9.1/Source -I/tmp/mysql5.7sc/cmake-3.9.1/Source/LexerParser -I/tmp/mysql5.7sc/cmake-3.9.1/Utilities -c /tmp/mysql5.7sc/cmake-3.9.1/Source/cmAddCustomTargetCommand.cxx -o cmAddCustomTargetCommand.o 。。。。。。。。。。。。。。 省略 。。。。。。。。。。。。。。。 -- Installing: /usr/local/bin/cmake -- Installing: /usr/local/bin/ctest -- Installing: /usr/local/bin/cpack -- Installing: /usr/local/share/cmake-3.9/include/cmCPluginAPI.h -- Installing: /usr/local/share/cmake-3.9/editors/vim/indent -- Installing: /usr/local/share/cmake-3.9/editors/vim/indent/cmake.vim -- Installing: /usr/local/share/cmake-3.9/editors/vim/syntax -- Installing: /usr/local/share/cmake-3.9/editors/vim/syntax/cmake.vim -- Installing: /usr/local/share/cmake-3.9/editors/emacs/cmake-mode.el -- Installing: /usr/local/share/aclocal/cmake.m4 -- Installing: /usr/local/share/cmake-3.9/completions/cmake -- Installing: /usr/local/share/cmake-3.9/completions/cpack -- Installing: /usr/local/share/cmake-3.9/completions/ctest [root@LHRDB cmake-3.9.1]# which cmake /usr/local/bin/cmake [root@LHRDB cmake-3.9.1]# cmake -version cmake version 3.9.1
|
重新开一个shell并继续编译:
[root@LHRDB mysql57]# cmake / > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 / > -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data / > -DMYSQL_USER=mysql / > -DWITH_INNOBASE_STORAGE_ENGINE=1 / > -DWITH_ARCHIVE_STORAGE_ENGINE=1 / > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 / > -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 / > -DWITH_READLINE=1 / > -DDOWNLOAD_BOOST=1 / > -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/ CMake Deprecation Warning at CMakeLists.txt:26 (CMAKE_POLICY): The OLD behavior for policy CMP0018 will be removed from a future version of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:32 (CMAKE_POLICY): The OLD behavior for policy CMP0022 will be removed from a future version of CMake. 。。。。。。。。省略部分。。。。。。。。 The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD.
-- INSTALL mysqlclient.pc lib/pkgconfig -- Skipping deb packaging on unsupported platform . -- CMAKE_BUILD_TYPE: RelWithDebInfo -- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT1 -- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -- CMAKE_C_LINK_FLAGS: -- CMAKE_CXX_LINK_FLAGS: -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- Configuring done -- Generating done -- Build files have been written to: /usr/local/mysql57sc/mysql57
|
成功。
该过程最慢。。。。。虚拟机约40分钟。。。。
[root@LHRDB mysql57]# make && make install Scanning dependencies of target abi_check [ 0%] Built target abi_check Scanning dependencies of target INFO_SRC [ 0%] Built target INFO_SRC Scanning dependencies of target INFO_BIN [ 0%] Built target INFO_BIN Scanning dependencies of target zlib [ 0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/gzio.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/infback.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/inffast.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/inflate.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/inftrees.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/trees.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/uncompr.c.o [ 0%] Building C object zlib/CMakeFiles/zlib.dir/zutil.c.o 。。。。。。。。。。省略部分。。。。。。。。。。。。 -- Installing: /usr/local/mysql57sc/mysql57/share/fill_help_tables.sql -- Installing: /usr/local/mysql57sc/mysql57/share/mysql_sys_schema.sql -- Installing: /usr/local/mysql57sc/mysql57/share/mysql_test_data_timezone.sql -- Installing: /usr/local/mysql57sc/mysql57/share/mysql_security_commands.sql -- Installing: /usr/local/mysql57sc/mysql57/lib/pkgconfig/mysqlclient.pc -- Installing: /usr/local/mysql57sc/mysql57/bin/mysql_config -- Installing: /usr/local/mysql57sc/mysql57/bin/mysqldumpslow -- Installing: /usr/local/mysql57sc/mysql57/bin/mysqld_multi -- Installing: /usr/local/mysql57sc/mysql57/bin/mysqld_safe -- Installing: /usr/local/mysql57sc/mysql57/share/aclocal/mysql.m4 [root@LHRDB mysql57]# [root@LHRDB mysql57]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_rootlhr-Vol00 9.9G 4.7G 4.8G 50% / tmpfs 2.0G 72K 2.0G 1% /dev/shm /dev/sda1 194M 35M 150M 19% /boot /dev/mapper/vg_rootlhr-Vol01 3.0G 1.6G 1.3G 56% /tmp /dev/mapper/vg_rootlhr-Vol03 3.0G 69M 2.8G 3% /home /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57 5.0G 2.7G 2.0G 58% /var/lib/mysql57 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_56 2.0G 1.4G 575M 70% /usr/local/mysql56 /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_55 2.0G 848M 1.1G 45% /usr/local/mysql55 /dev/sr0 3.6G 3.6G 0 100% /media/lhr/cdrom /dev/mapper/vg_mysqlsoft-lv_mysqlsoft_57sc 9.9G 7.2G 2.2G 77% /usr/local/mysql57sc .host:/ 331G 273G 58G 83% /mnt/hgfs |
用了大概7.2G,太费空间了。最后的make和make install大概用了40分钟,太费时间了。。。。。
注意:MySQL 5.7.6之后的版本初始化数据库不再使用mysql_install_db
[root@LHRDB mysql57]# mkdir log [root@LHRDB mysql57]# chown mysql.mysql log [root@LHRDB mysql57]# pwd /usr/local/mysql57sc/mysql57 [root@LHRDB mysql57]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql57sc/mysql57 --datadir=/usr/local/mysql57sc/mysql57/data 2017-08-28T08:34:01.250285Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-28T08:34:02.675706Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-08-28T08:34:02.743783Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-08-28T08:34:02.847128Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a572bb0e-8bcb-11e7-b92e-000c291823c2. 2017-08-28T08:34:02.848708Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-08-28T08:34:02.851802Z 1 [Note] A temporary password is generated for root@localhost: N9eYPaqv4q!X |
这里生成的临时密码为:N9eYPaqv4q!X
修改文件/etc/my.cnf,加入以下内容:
[mysqld573309] basedir=/usr/local/mysql57sc/mysql57 datadir=/usr/local/mysql57sc/mysql57/data socket=/usr/local/mysql57sc/mysql57/mysql.sock log-error=/usr/local/mysql57sc/mysql57/log/mysqld.log user=mysql port=3309 |
[root@LHRDB mysql5719]# echo '' > /usr/local/mysql57sc/mysql57/log/mysqld.log [root@LHRDB mysql5719]# chown mysql.mysql /usr/local/mysql57sc/mysql57/log/mysqld.log [root@LHRDB data]# mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld57 is running MySQL server from group: mysqld56 is running MySQL server from group: mysqld55 is running MySQL server from group: mysqld573309 is not running [root@LHRDB data]# mysqld_multi start 573309 [root@LHRDB data]# mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld57 is running MySQL server from group: mysqld56 is running MySQL server from group: mysqld55 is running MySQL server from group: mysqld573309 is running [root@LHRDB data]# netstat -lntp | grep mysqld tcp 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 12932/mysqld tcp 0 0 :::3307 :::* LISTEN 12858/mysqld tcp 0 0 :::3309 :::* LISTEN 29785/mysqld tcp 0 0 :::3306 :::* LISTEN 12880/mysqld
|
[root@LHRDB data]# mysql -uroot --socket=/usr/local/mysql57sc/mysql57/mysql.sock -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 4 Server version: 5.7.19
Copyright (c) 2000, 2017, 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> set password=password('lhr'); Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select @@port; +--------+ | @@port | +--------+ | 3309 | +--------+ 1 row in set (0.00 sec)
|
修改密码也可以用:update mysql.user set authentication_string=password('lhr') where user='root';
mysql> grant all privileges on *.* to root@'%' identified by 'lhr'; Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from mysql.user; +-----------+---------------+ | host | user | +-----------+---------------+ | % | root | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +-----------+---------------+ 4 rows in set (0.00 sec)
|
在Windows下远程登录:
D:/Users/xiaomaimiao>mysql -uroot -plhr -h192.168.59.159 -P3309 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 5 Server version: 5.7.19 Source distribution
Copyright (c) 2000, 2014, 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 | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
mysql>
|
[root@LHRDB ~]# service mysqld_multi start WARNING: my_print_defaults command not found. Please make sure you have this command available and in your path. The command is available from the latest MySQL distribution. WARNING: Log file disabled. Maybe directory or file isn't writable? ABORT: Can't find command 'my_print_defaults'. This command is available from the latest MySQL distribution. Please make sure you have the command in your PATH.
|
解决:
编辑文件:/etc/init.d/mysqld_multi,添加:. /etc/profile,或者在文件/etc/init.d/mysqld_multi中加入下面的变量:
MYSQL_HOME=/var/lib/mysql57/mysql5719 PATH=$MYSQL_HOME/bin:$PATH |
CMake Error at cmake/boost.cmake:81 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST= This CMake script will look for boost in it will download and unpack it (in that directory) for you.** |
解决办法:
cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/mysql-5.7.19/boost/boost_1_59_0/ |
或者在执行cmake命令时加上DOWNLOAD_BOOST和WITH_BOOST参数。
官方文档:
https://dev.mysql.com/doc/refman/5.7/en/checking-rpm-signature.html
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html
源码编译安装的更多内容:http://blog.itpub.net/26736162/viewspace-2144212/
rpm的安装方式请参考:
http://blog.itpub.net/26736162/viewspace-1349705/
http://blog.itpub.net/26736162/viewspace-1349787/
OS路径设置:
vgcreate vg_mysqlsoft /dev/sdb1 lvcreate -n lv_mysqlsoft_57 -L 5G vg_mysqlsoft mkfs.ext4 /dev/vg_mysqlsoft/lv_mysqlsoft_57 mkdir -p /tmp/mysql5719 mkdir -p /var/lib/mysql57 mount /dev/vg_mysqlsoft/lv_mysqlsoft_57 /var/lib/mysql57/ vi /etc/fstab |
二进制安装过程:
md5sum mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /var/lib/mysql57/ mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql5719
groupadd mysql useradd -r -g mysql mysql
MySQL 5.6版本:./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql56/mysql5637 --datadir=/usr/local/mysql56/mysql5637/data MySQL 5.7版本:./bin/mysqld --initialize --user=mysql --basedir=/var/lib/mysql57/mysql5719 --datadir=/var/lib/mysql57/mysql5719/data more /etc/my.cnf
cp mysql.server /etc/init.d/mysql57 chmod 755 /etc/init.d/mysql57 chkconfig --add mysql57 chkconfig mysql57 on chkconfig --level 345 mysql57 on
mysqld_safe --user=mysql &
MYSQL_HOME=/var/lib/mysql57/mysql5719 PATH=$PATH:$MYSQL_HOME/bin source /etc/profile
#MySQL 5.7初始化时有默认密码,5.6无密码 mysql -uroot --socket=/usr/local/mysql56/mysql5637/mysql.sock -p set password=password('lhr'); update mysql.user set authentication_string=password('lhr') where user='root'; grant all privileges on *.* to root@'%' identified by 'lhr'; flush privileges;
|
源码安装:
tar -zxf /tmp/mysql5.7sc/mysql-5.7.19.tar.gz -C /usr/local/mysql57sc/ tar -zxf /tmp/mysql5.7sc/mysql-boost-5.7.19.tar.gz -C /usr/local/mysql57sc/ mv mysql-5.7.19 mysql57
yum install -y cmake make gcc gcc-c++ ncurses-devel #cmake最低需要2.8.2版本的
cmake / > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57sc/mysql57 / > -DMYSQL_DATADIR=/usr/local/mysql57sc/mysql57/data / > -DMYSQL_USER=mysql / > -DWITH_INNOBASE_STORAGE_ENGINE=1 / > -DWITH_ARCHIVE_STORAGE_ENGINE=1 / > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 / > -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 / > -DWITH_READLINE=1 / > -DDOWNLOAD_BOOST=1 / > -DWITH_BOOST=/usr/local/mysql57sc/mysql57/boost/boost_1_59_0/
make && make install |
查看MySQL的端口:
netstat -lntp | grep mysqld |
版权声明:本文为博主原创文章,未经博主允许不得转载。