MySQL5.7.22版本的安装和调试
Posted lhh0419
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL5.7.22版本的安装和调试相关的知识,希望对你有一定的参考价值。
1:安装前的准备工作
需要的软件:
boost_1_59_0.tar.gz,cmake-3.6.1.tar.gz,mysql-5.7.22.tar.gz
开始安装MySQL
2.1 检查cmake
[[email protected] cmake-3.6.1]# ./bootstrap && make && make install
2.2 开始编译安装mysql
创建用户和组
[[email protected] cmake-3.6.1]#groupadd mysql
[[email protected] cmake-3.6.1]#useradd -g mysql -s /sbin/nologin -M mysql
创建安装数据库的目录和数据存放目录
[[email protected] src]# mkdir mysql5
[[email protected] src]# mkdir mysql
2.2.1 解压数据库软件
[[email protected] src]# tar -xvf mysql-5.7.22.tar.gz
[[email protected] 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
[[email protected] 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的文件夹
- mkdir -p /usr/local/boost
- 把上面的名为boost_1_59_0.tar.gz的压缩包解压就可以了
- tar -xvf boost_1_59_0.tar.gz
继续CMAKE 这里要注意红色的部分
[[email protected] 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
[[email protected] mysql-5.7.22]# make && make install
把配置文件拷贝到/etc 下
通过上面的截图我们不难发现 没有我们要找的配置文件,难道5.7.22版本不需要配置文件了吗,我们先不管,接着往下做
[[email protected] mysql-5.7.22]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql-5.7.22]# chmod +x /etc/init.d/mysqld
[[email protected] mysql-5.7.22]# chkconfig --add mysqld
初始化MySQL数据库
注:在5.7.22版本中mysql_install_db 被废弃了,取而代之的是 mysqld –initialize
[[email protected] 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] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.
注:这些警告信息不用管,只要没有error 就可以
2.2.3 我们尝试启动MySQL服务
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to ‘/data/src/mysql5/oracle.err‘.
SUCCESS!
数据库启动成功,因此 MySQL.5.7.22版本没有配置文件也是可以的。
[[email protected] mysql5]# echo ‘/data/src/mysql/include/‘ >> /etc/ld.so.conf
[[email protected] mysql5]# echo ‘/data/src/mysql/lib/‘ >> /etc/ld.so.conf
[[email protected] 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
[[email protected] 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
[[email protected] mysql5]# mysqladmin -u root password ‘m2i3sc‘
mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO)‘
我们现在看一下每个schema的文件和之前有什么不同
[[email protected] mysql5]# ls auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 ibtmp1 lhh mysql oracle.err oracle.pid performance_schema sys [[email protected] mysql5]# cd lhh [[email protected] lhh]# ls db.opt emp.frm emp.ibd test.frm test.ibd [[email protected] lhh]#
注意上面标记的红色的部分,这个在以前的5.6的版本中是没有这个文件的,存的表的结构,它所有的数据存在ibdata1 的这个文件中,这也是5.7版本的新特性。
至此,mysql-5.7.22版本的安装就算完成了。