1:安裝前的準備工做mysql
須要的軟件:c++
boost_1_59_0.tar.gz,cmake-3.6.1.tar.gz,mysql-5.7.22.tar.gzsql
開始安裝MySQL數據庫
2.1 檢查cmakebootstrap
[root@oracle cmake-3.6.1]# ./bootstrap && make && make install
oracle
2.2 開始編譯安裝mysql ide
建立用戶和組sqlserver
[root@oracle cmake-3.6.1]#groupadd mysqlui
[root@oracle cmake-3.6.1]#useradd -g mysql -s /sbin/nologin -M mysqlthis
建立安裝數據庫的目錄和數據存放目錄
[root@oracle src]# mkdir mysql5
[root@oracle src]# mkdir mysql
2.2.1 解壓數據庫軟件
[root@oracle src]# tar -xvf mysql-5.7.22.tar.gz
[root@oracle mysql-5.7.22]# cmake . -DCMAKE_INSTALL_PREFIX=/data/src/mysql -DMYSQL_DATADIR=/data/src/mysql5 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0
[root@oracle mysql-5.7.22]# cmake . -DCMAKE_INSTALL_PREFIX=/data/src/mysql -DMYSQL_DATADIR=/data/src/mysql5 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -- Running cmake version 3.6.1 -- Could NOT find Git (missing: GIT_EXECUTABLE) -- Configuring with MAX_INDEXES = 64U -- The C compiler identification is GNU 4.4.7 -- The CXX compiler identification is GNU 4.4.7 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- CMAKE_GENERATOR: Unix Makefiles -- Looking for SHM_HUGETLB -- Looking for SHM_HUGETLB - found -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void * -- Check size of void * - done -- SIZEOF_VOIDP 8 -- Performing Test HAVE_C_SHIFT_OR_OPTIMIZATION_BUG -- Performing Test HAVE_C_SHIFT_OR_OPTIMIZATION_BUG - Failed -- Performing Test HAVE_CXX_SHIFT_OR_OPTIMIZATION_BUG -- Performing Test HAVE_CXX_SHIFT_OR_OPTIMIZATION_BUG - Failed -- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD -- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD - Failed -- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD -- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD - Failed -- Performing Test HAVE_C_FP_CONTRACT_FLAG -- Performing Test HAVE_C_FP_CONTRACT_FLAG - Failed -- Performing Test HAVE_CXX_FP_CONTRACT_FLAG -- Performing Test HAVE_CXX_FP_CONTRACT_FLAG - Failed -- MySQL 5.7.22 -- Packaging as: mysql-5.7.22-Linux-x86_64 -- Looked for boost/version.hpp in and -- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND -- LOCAL_BOOST_DIR -- LOCAL_BOOST_ZIP -- Could not find (the correct version of) boost. -- MySQL currently requires boost_1_59_0 CMake Error at cmake/boost.cmake:81 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory> This CMake script will look for boost in <directory>. If it is not there, it will download and unpack it (in that directory) for you. If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80 Call Stack (most recent call first): cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST) CMakeLists.txt:506 (INCLUDE) -- Configuring incomplete, errors occurred! See also "/data/src/mysql-5.7.22/CMakeFiles/CMakeOutput.log". See also "/data/src/mysql-5.7.22/CMakeFiles/CMakeError.log
這個的解決方法是:
在/usr/local下建立一個名爲boost的文件夾
繼續CMAKE 這裏要注意紅色的部分
[root@oracle src]# cmake . -DCMAKE_INSTALL_PREFIX=/data/src/mysql -DMYSQL_DATADIR=/data/src/mysql5 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DWITH_BOOST=/usr/local/boost -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 這是根據剛纔按裝的路徑添加的
17 sql/CMakeLists.txt:572 (INCLUDE) 18 19 20 CMake Warning at cmake/bison.cmake:20 (MESSAGE): 21 Bison executable not found in PATH 22 Call Stack (most recent call first): 23 libmysqld/CMakeLists.txt:205 (INCLUDE) 24 25 26 -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio 27 -- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver 28 -- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;crypt;dl;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded 29 -- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;yassl;taocrypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded 30 -- library target mysqlserver debug_target /data/src/debug/archive_output_directory/libmysqld.a 31 -- INSTALL mysqlclient.pc lib/pkgconfig 32 -- Skipping deb packaging on unsupported platform . 33 -- CMAKE_BUILD_TYPE: RelWithDebInfo 34 -- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_LIBEVENT1 35 -- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement 36 -- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter 37 -- CMAKE_C_LINK_FLAGS: 38 -- CMAKE_CXX_LINK_FLAGS: 39 -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF 40 -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF 41 -- Configuring done 42 -- Generating done 43 -- Build files have been written to: /data/src/mysql-5.7.22
看到上面的信息就證實cmake 成功了
2.2.2
[root@oracle mysql-5.7.22]# make && make install
把配置文件拷貝到/etc 下
經過上面的截圖咱們不難發現 沒有咱們要找的配置文件,難道5.7.22版本不須要配置文件了嗎,咱們先無論,接着往下作
[root@oracle mysql-5.7.22]# cp support-files/mysql.server /etc/init.d/mysqld
[root@oracle mysql-5.7.22]# chmod +x /etc/init.d/mysqld
[root@oracle mysql-5.7.22]# chkconfig --add mysqld
初始化MySQL數據庫
注:在5.7.22版本中mysql_install_db 被廢棄了,取而代之的是 mysqld –initialize
[root@oracle mysql]# bin/mysqld --initialize-insecure --user=mysql --basedir=/data/src/mysql/ --datadir=/data/src/mysql5
2018-05-24T07:07:55.314350Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-24T07:07:56.262284Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-24T07:07:56.407878Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-24T07:07:56.494757Z 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: 2f2eaae3-5f21-11e8-ab77-000c29e94efc.
2018-05-24T07:07:56.497669Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-24T07:07:56.512801Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
注:這些警告信息不用管,只要沒有error 就能夠
2.2.3 咱們嘗試啓動MySQL服務
[root@oracle mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/src/mysql5/oracle.err'.
SUCCESS!
數據庫啓動成功,所以 MySQL.5.7.22版本沒有配置文件也是能夠的。
[root@oracle mysql5]# echo '/data/src/mysql/include/' >> /etc/ld.so.conf
[root@oracle mysql5]# echo '/data/src/mysql/lib/' >> /etc/ld.so.conf
[root@oracle mysql5]# ldconfig
2.2.4 施工後校驗,這裏是沒有初始化用戶的
這個比5.6的版本多了sys 庫少了test
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> update mysql.user set authentication_string=password('m2i3sc') where user='root' ;
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@oracle mysql5]# mysql -uroot -pm2i3sc
mysql: [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 3
Server version: 5.7.22 Source distribution
Copyright (c) 2000, 2018, 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> exit
Bye
[root@oracle mysql5]# mysqladmin -u root password 'm2i3sc'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
咱們如今看一下每一個schema的文件和以前有什麼不一樣
[root@oracle mysql5]# ls
auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 ibtmp1 lhh mysql oracle.err oracle.pid performance_schema sys
[root@oracle mysql5]# cd lhh
[root@oracle lhh]# ls
db.opt emp.frm emp.ibd test.frm test.ibd
[root@oracle lhh]#
注意上面標記的紅色的部分,這個在之前的5.6的版本中是沒有這個文件的,存的表的結構,它全部的數據存在ibdata1 的這個文件中,這也是5.7版本的新特性。
至此,mysql-5.7.22版本的安裝就算完成了。