mySQL (关系型数据库管理系统)
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,
目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,
在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database
Management System,关系数据库管理系统) 应用软件。
系统环境
Centos7.3
MySQL-5.7.20下载地址https://dev.mysql.com/downloa...
MySQL-client-5.7.20下载地址:https://dev.mysql.com/downloa...
Cmake-3.8.2 下载地址:https://cmake.org/files/v3.8/...
-
不想去官网下载的可以直接去云盘下载。
百度云盘:链接:http://pan.baidu.com/s/1c2tq6Y0 密码:26o2
开始安装
-
解压,编译安装cmake
**需要先安装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变量
-
解压,编译安装MySQL
**安装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
-
编辑 /etc/my.cnf 文件
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
-
创建mysql用户
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
安装MySQLclient
-
解压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
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。