MySQL是一個關係型數據庫管理系統,由瑞典MySQL AB 公司開發, 目前屬於 Oracle 旗下產品。MySQL 是最流行的關係型數據庫管理系統之一, 在 WEB 應用方面,MySQL是最好的 RDBMS (Relational Database Management System,關係數據庫管理系統) 應用軟件。
官網:https://www.mysql.com/java
Centos7.3python
MySQL-5.7.20下載地址https://dev.mysql.com/downloa...mysql
MySQL-client-5.7.20下載地址:https://dev.mysql.com/downloa...c++
Cmake-3.8.2 下載地址:https://cmake.org/files/v3.8/...sql
不想去官網下載的能夠直接去雲盤下載。數據庫
百度雲盤:連接:http://pan.baidu.com/s/1c2tq6Y0 密碼:26o2
解壓,編譯安裝cmakevim
**須要先安裝gcc編譯軟件** yum install gcc gcc-c++ -y tar -zxvf cmake-3.8.2.tar.gz cd cmake-3.8.2 ./configure --prefix=/usr/local/cmake-3.8.2 make && make install PATH=/usr/local/cmake-3.8.2/bin/:$PATH ##加入PATH變量
解壓,編譯安裝MySQLcentos
**安裝MySQL依賴文件** yum install ncurses-devel -y **雲盤裏有boost_1_59_0.tar.bz2文件下載解壓便可** tar -jxvf boost_1_59_0.tar.bz2 -C /usr/local/boost_1_59_0 **解壓編譯MySQL** tar -zxvf mysql-5.7.20.tar.gz cd mysql-5.7.20 **建立cmake編譯腳本** cat >>cmake.sh<<EOF cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.20 \ ##mysql程序編譯路徑 -DDEFAULT_CHARSET=utf8 \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_BOOST=/usr/local/boost_1_59_0/ EOF chmod +x cmake.sh sh cmake.sh **編譯須要很長時間,儘可能內存,和CPU給大一點。** make -j4 && make install 這個時候就去喝茶吧,大約須要40分鐘左右,根據電腦速度快慢決定
編輯 /etc/my.cnf 文件api
vim /etc/my.cnf [mysqld] datadir=/usr/local/mysql-5.7.20/data/ socket=/usr/local/mysql-5.7.20/data/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd #[mysqld_safe] #log-error=/var/log/mariadb/mariadb.log #pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # #!includedir /etc/my.cnf.d [mysql] socket=/usr/local/mysql-5.7.20/data/mysql.sock **保存退出**
建立mysql用戶bash
useradd mysql -u 27 -s /sbin/nologin groupmod -g 27 mysql **查看用戶是否建立成功** id mysql uid=27(mysql) gid=27(mysql) 組=27(mysql)
進入MySQL安裝目錄
cd /usr/local/mysql-5.7.20/ mkdir data ## **建立mysql庫文件夾**
更改mysql-5.7.20全部者 所屬組爲mysql
chown -R mysql:mysql /usr/local/mysql-5.7.20 chmod 2755 /usr/local/mysql-5.7.20
初始化以前先移除/eyc/my.cnf文件不然會有報錯
mv /etc/my.cnf{,.bak}
初始化MySQL庫文件
cd /usr/local/mysql-5.7.20/ ./bin/mysqld --initialize --user=mysql 2017-11-21T08:22:43.169383Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-11-21T08:22:44.688218Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-11-21T08:22:45.065788Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-11-21T08:22:45.091960Z 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: 26963eb6-ce95-11e7-a692-005056309a18. 2017-11-21T08:22:45.093539Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-11-21T08:22:45.094792Z 1 [Note] A temporary password is generated for root@localhost: f,AWeEh_%8Il ##mysql 初始密碼。
啓動MySQL進程
./bin/mysqld_safe --user=mysql &
cp /usr/local/mysql-5.7.20/support-files/mysql.server /etc/init.d/mysqld service mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! chkconfig mysqld on
解壓mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar -C /mysql
建立mysql yum源。
cd /mysql createrepo . ##生成repo索引 vim /etc/yum.repo.d/mysql.repo [mysql] name='mysql' baseurl=file:///mysql enbaled=1 gpgcheck=0
安裝MySQL client 客戶端
yum install mysql-community-client 總下載量:24 M 安裝大小:106 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : mysql-community-client-5.7.20-1.el7.x86_64 1/1 驗證中 : mysql-community-client-5.7.20-1.el7.x86_64 1/1 已安裝: mysql-community-client.x86_64 0:5.7.20-1.el7 完畢!
鏈接MySQL-service
**將剛纔更改的/etc/my.cnf.bak 恢復過來** mv /etc/my.cnf.bak /etc/my.cnf **鏈接測試** mysql -uroot -p‘f,AWeEh_%8Il’## 剛纔MySQL初始數據庫隨機成成的密碼 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 5 Server version: 5.7.20 Source distribution 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>
更改初始密碼
mysql> set password for 'root'@'localhost'=password('newpasswd');
cmake 錯誤0:
[root@localhost mysql-5.7.19]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ > -DSYSCONFDIR=/etc \ > -DMYSQL_TCP_PORT=3306 \ > -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ > -DEFAULT_CHARSET=utf8 \ > -DMYSQL_DATADIR=/usr/local/mysql/data \ > -DENABLED_LOCAL_INFILE=1 \ > -DEXTRA_CHARSETS=all \ > -DDEFAULT_COLLATION=utf8_general_ci \ > -DDOWNLOAD_BOOST=1 \ > -DWITH_BOOST=/usr/local/src/boost_1_59_0 -- Running cmake version 2.8.11 -- Could NOT find Git (missing: GIT_EXECUTABLE) -- Configuring with MAX_INDEXES = 64U -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name. CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. -- CMAKE_GENERATOR: Unix Makefiles CMake Error at cmake/os/Linux.cmake:41 (MESSAGE): Unsupported compiler! Call Stack (most recent call first): CMakeLists.txt:169 (INCLUDE) -- Configuring incomplete, errors occurred! [root@localhost mysql-5.7.19]# gcc bash: gcc: 未找到命令... **報錯緣由:沒安裝gcc**
cmake 報錯1:
[root@CentOS73-1 mysql-5.7.19]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/ var/lib/mysql/mysql.sock -DEFAULT_CHA RSET=utf8 -DMYSQL_DATADIR=/usr/local/mysql/data -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci - DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/loca l/src/boost_1_59_0 -- Running cmake version 2.8.12.2 -- Could NOT find Git (missing: GIT_EXECUTABLE) -- Configuring with MAX_INDEXES = 64U -- The CXX compiler identification is unknown CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. -- CMAKE_GENERATOR: Unix Makefiles -- SIZEOF_VOIDP 8 -- MySQL 5.7.19 -- Packaging as: mysql-5.7.19-Linux-x86_64 -- Local boost dir /usr/local/src/boost_1_59_0 -- Found /usr/local/src/boost_1_59_0/boost/version.hpp -- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900 -- BOOST_INCLUDE_DIR /usr/local/src/boost_1_59_0 -- NUMA library missing or required version not available -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:64 (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 ncursesdevel. Call Stack (most recent call first): cmake/readline.cmake:107 (FIND_CURSES) cmake/readline.cmake:197 (MYSQL_USE_BUNDLED_EDITLINE) CMakeLists.txt:519 (MYSQL_CHECK_EDITLINE) -- Configuring incomplete, errors occurred! See also "/usr/local/src/mysql-5.7.19/CMakeFiles/CMakeOutput.log". See also "/usr/local/src/mysql-5.7.19/CMakeFiles/CMakeError.log". **報錯緣由:沒安裝 ncurses-devel**
cmake報錯2:
CMake Error: Internal CMake error, TryCompile configure of cmake failed -- Performing Test HAVE_NO_BUILTIN_MEMCMP - Failed CMake Warning at cmake/bison.cmake:20 (MESSAGE): Bison executable not found in PATH Call Stack (most recent call first): sql/CMakeLists.txt:548 (INCLUDE) CMake Warning at cmake/bison.cmake:20 (MESSAGE): Bison executable not found in PATH Call Stack (most recent call first): libmysqld/CMakeLists.txt:187 (INCLUDE) -- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl -- 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: -- 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: -DDBUG_OFF -- Configuring incomplete, errors occurred! See also "/usr/local/src/mysql-5.7.19/CMakeFiles/CMakeOutput.log". See also "/usr/local/src/mysql-5.7.19/CMakeFiles/CMakeError.log". 報錯緣由:沒有安裝gcc-c++
make 出錯 1:
[root@CentOS73-1 mysql-5.7.19]# make -j4 [ 0%] Built target zlib [ 0%] Built target INFO_BIN [ 0%] Built target INFO_SRC [ 1%] Built target yassl [ 3%] Built target taocrypt [ 5%] Built target edit [ 7%] Built target strings [ 8%] Built target mysqlservices Linking C static library liblz4_lib.a [ 8%] Built target gen_lex_hash [ 8%] Built target vio [ 8%] [ 9%] Built target lz4_lib Built target regex [ 9%] Built target comp_sql [ 9%] Built target abi_check [ 9%] [ 10%] [ 10%] Building CXX object rapid/plugin/group_replication/CMakeFiles/gr_unit_test_resource.dir/src/member_info.cc.o Built target event Scanning dependencies of target protobuf-lite Built target GenLiteProtos Scanning dependencies of target protobuf Scanning dependencies of target protoclib [ 10%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/stubs/ atomicops_internals_x86_gcc.cc.o In file included from /usr/local/src/mysql-5.7.19/rapid/plugin/group_replication/include/plugin_server_include.h:38:0, from /usr/local/src/mysql-5.7.19/rapid/plugin/group_replication/include/plugin_psi.h:19, from /usr/local/src/mysql-5.7.19/rapid/plugin/group_replication/src/member_info.cc:17: /usr/local/src/mysql-5.7.19/include/my_atomic.h:64:4: error: #error Native atomics support not found! # error Native atomics support not found! ^ [ 10%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/code_generator.cc.o [ 10%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/strutil.cc.o [ 10%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/stubs/ atomicops_internals_x86_msvc.cc.o make[2]: *** [rapid/plugin/group_replication/CMakeFiles/gr_unit_test_resource.dir/src/member_info.cc.o] Error 1 make[1]: *** [rapid/plugin/group_replication/CMakeFiles/gr_unit_test_resource.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 10%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/stubs/common.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/stubs/once.cc.o [ 11%] [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/stubs/stringprintf.cc.o Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/command_line_interface.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/extension_set.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/generated_message_util.cc.o [ 11%] [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/substitute.cc.o Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/message_lite.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/structurally_valid.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/repeated_field.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/descriptor.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/wire_format_lite.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/io/coded_stream.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/io/zero_copy_stream.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf-lite.dir/protobuf-2.6.1/src/google/protobuf/io/zero_copy_stream_impl_lite.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/descriptor.pb.cc.o Linking CXX static library libprotobuf-lite.a [ 11%] Built target protobuf-lite [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/descriptor_database.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/plugin.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/plugin.pb.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/dynamic_message.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/subprocess.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/zip_writer.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/extension_set_heavy.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_enum.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/generated_message_reflection.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_enum_field.cc.o [ 11%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/message.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_extension.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/reflection_ops.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/service.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/text_format.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/unknown_field_set.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/wire_format.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/gzip_stream.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_field.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/printer.cc.o [ 12%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/strtod.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/tokenizer.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/zero_copy_stream_impl.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_file.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/compiler/importer.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/compiler/parser.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_generator.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/common.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/once.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_helpers.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/stubs/stringprintf.cc.o [ 13%] [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_message.cc.o Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/extension_set.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/generated_message_util.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/message_lite.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_message_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/repeated_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/wire_format_lite.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/coded_stream.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/zero_copy_stream.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/io/zero_copy_stream_impl_lite.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_service.cc.o Linking CXX static library libprotobuf.a [ 13%] Built target protobuf [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/cpp/cpp_string_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_context.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_enum.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_enum_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_extension.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_field.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_file.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_generator.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/ java_generator_factory.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_helpers.cc.o [ 13%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/ java_lazy_message_field.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_message.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_message_field.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_name_resolver.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/ java_primitive_field.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/ java_shared_code_generator.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_service.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_string_field.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/java/java_doc_comment.cc.o [ 14%] Building CXX object extra/protobuf/CMakeFiles/protoclib.dir/protobuf-2.6.1/src/google/protobuf/compiler/python/python_generator.cc.o Linking CXX static library libprotoclib.a [ 14%] Built target protoclib make: *** [all] Error 2 **報錯緣由:cmake 版本過低**
編譯安裝 cmake :
[root@CentOS73-1 cmake-3.9.1]# ./configure [root@CentOS73-1 cmake-3.9.1]# make [root@CentOS73-1 cmake-3.9.1]# make install [root@CentOS73-1 ~]# cd /usr/local/src/mysql-5.7.19/ [root@CentOS73-1 mysql-5.7.19]# rm -rf CMakeCache.txt 退出終端,重進 從新 cmake , make ,make install cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_BOOST=/usr/local/src/boost_1_59_0
make 出錯 2:
[ 78%] Building CXX object rapid/plugin/x/CMakeFiles/mysqlx.dir/generated/protobuf_lite/mysqlx_resultset.pb.cc.o [ 78%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/item_geofunc_buffer.cc.o [ 78%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/item_geofunc_internal.cc.o [ 78%] Linking CXX shared module mysqlx.so [ 79%] Built target mysqlx [ 79%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/item_geofunc_relchecks.cc.o c++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/__/sql/item_geofunc.cc.o] Error 4 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2 make: *** [all] Error 2 **錯誤緣由:內存不不夠 make -j4 啓動 4 個gcc 進程耗費內存過⼤大**
[實踐發現]在編譯mysql5.7.12時在編譯⼀一半時出現錯誤,實際上是郵於阿⾥裏里vps內存不不⾜足所致使。
背景:⽤用阿⾥裏里雲編譯mysql5.7.12時在編譯⼀一半時出現錯誤,以下: [ 50%] Building CXX object sql/CMakeFiles/sql.dir/item_cmpfunc.cc.o [ 50%] Building CXX object sql/CMakeFiles/sql.dir/item_create.cc.o [ 50%] Building CXX object sql/CMakeFiles/sql.dir/item_func.cc.o [ 50%] Building CXX object sql/CMakeFiles/sql.dir/item_geofunc.cc.o c++: 編譯器器內部錯誤:已殺死(程序 cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] 錯誤 4 make[1]: *** [sql/CMakeFiles/sql.dir/all] 錯誤 2 make: *** [all] 錯誤 2 不不要感受奇怪,實際上是內存不不夠致使的,這位兄弟也遇到⼀同樣的問題,以下: 在這⾥裏里特別提醒, 對於mysql5.7.8的make編譯, 若是是阿⾥裏里雲centos主機512M內存的, 會在make編譯到45%時會報錯, 這是內存不不⾜足所致。 c++: Internal error: Killed (program cc1plus) Please submit a full bug report. See <http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 1 make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2 make: *** [all] Error 2 那麼設置2G交換分區來⽤用下 : # dd if=/dev/zero of=/swapfile bs=1k count=2048000 --獲取要增長的2G的SWAP⽂文件塊 # mkswap /swapfile -- 建立SWAP⽂文件 # swapon /swapfile -- 激活SWAP⽂文件 # swapon -s -- 查看SWAP信息是否正確 # echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab -- 添加到fstab⽂文件中讓系統引導時⾃自動啓動 注意, swapfile⽂文件的路路徑在/var/下 編譯完後, 若是不不想要交換分區了了, 能夠刪除: # swapoff /swapfile # rm -fr /swapfile
初始化報錯
mysql_install_db 命令已經不不同意使⽤用,須要使⽤用 mysqld 命令初始化數據庫⽬目錄
[root@centos74-0 mysql-5.7.19]# ./bin/mysql_install_db --user=mysql 2017-11-18 14:57:04 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2017-11-18 14:57:04 [ERROR] The data directory needs to be specified.
[root@centos74-0 mysql-5.7.19]# ./bin/mysqld --initialize
2017-11-18T06:57:28.845607Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details). 2017-11-18T06:57:29.129344Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-11-18T06:57:29.203844Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-11-18T06:57:29.263076Z 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: be136ee3-cc2d-11e7-b4a7-001c42ebb70f. 2017-11-18T06:57:29.264361Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-11-18T06:57:29.265114Z 1 [Note] A temporary password is generated for root@localhost: xkkJiMlmX3&s
[root@centos74-0 mysql-5.7.19]# ll -d data
drwxr-x--- 5 root root 147 Nov 18 14:57 data
[root@centos74-0 bin]# ./mysqld --initialize --user=mysql
2017-11-18T07:20:37.761916Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details). 2017-11-18T07:20:38.007055Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-11-18T07:20:38.055215Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-11-18T07:20:38.112842Z 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: f9e51e81-cc30-11e7-b3f5-001c42ebb70f. 2017-11-18T07:20:38.114500Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-11-18T07:20:38.115271Z 1 [Note] A temporary password is generated for root@localhost: I<XPKquuk0:u
[root@centos74-0 bin]# ./mysqld_safe --user=mysql
Logging to '/usr/local/mysql-5.7.20/data/centos74-0.err'. 2017-11-18T07:21:14.070919Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.20/data
[root@centos74-0 mysql-5.7.20]# ./bin/mysql -uroot -p'I<XPKquuk0:u'
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.20 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>
若是數據⽬目錄⾮非空,會認爲數據庫已存在,⽆沒法初始化
[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql 2017-11-18T07:25:50.083462Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-11-18T07:25:50.088292Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2017-11-18T07:25:50.088372Z 0 [ERROR] Aborting