前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS7中mysql-5.7.21-el7-x86_64.tar.gz版MySQL的安装与配置

CentOS7中mysql-5.7.21-el7-x86_64.tar.gz版MySQL的安装与配置

作者头像
耕耘实录
发布2018-12-20 14:38:09
1K0
发布2018-12-20 14:38:09
举报
文章被收录于专栏:耕耘实录耕耘实录耕耘实录

版权声明:本文为耕耘实录原创文章,各大自媒体平台同步更新。欢迎转载,转载请注明出处,谢谢

一、准备阶段

通常情况下,MySQL在CentOS下主要使用glibc、rpm、yum等方式进行安装,使用mysql-5.7.21-el7-x86_64.tar.gz包进行安装的很少见,网上资料也较少。通过一上午的摸索,总结出如下安装方法。

下载安装包:

[root@GeekDevOps ~]# curl -C - -O https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-el7-x86_64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  674M  100  674M    0     0  4311k      0  0:02:40  0:02:40 --:--:-- 4067k

创建安装账户:

[root@GeekDevOps ~]# useradd -s /bin/false -d /usr/local/mysql  mysql
[root@GeekDevOps ~]# id mysql
uid=1000(mysql) gid=1000(mysql) 组=1000(mysql)
二、安装过程
[root@GeekDevOps ~]# tar -xvzf mysql-5.7.21-el7-x86_64.tar.gz -C /usr/local/mysql/
[root@GeekDevOps mysql]# cd /usr/local/mysql/mysql-5.7.21-el7-x86_64/
[root@GeekDevOps mysql-5.7.21-el7-x86_64]# mv * ../
[root@GeekDevOps mysql-5.7.21-el7-x86_64]# cd ..
[root@GeekDevOps mysql]# rmdir mysql-5.7.21-el7-x86_64/
[root@GeekDevOps mysql]# mkdir data
[root@GeekDevOps mysql]# chown -R mysql.mysql ../mysql
[root@GeekDevOps mysql]# cd bin
[root@GeekDevOps bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
[root@GeekDevOps bin]# tail -100f ../data/error.log 
2018-03-14T06:32:34.966407Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-14T06:32:36.208273Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-03-14T06:32:36.367294Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-14T06:32:36.522777Z 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: 7c405e3f-2751-11e8-8be8-000c29fb0102.
2018-03-14T06:32:36.525594Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-03-14T06:32:36.526540Z 1 [Note] A temporary password is generated for root@localhost: 7Eu;dsRqkY.3
[root@GeekDevOps bin]# cp ../support-files/mysql.server /etc/init.d/mysqld
三、配置过程
[root@GeekDevOps ~]# vi /etc/my.cnf
[mysqld]
port = 3306
basedir = /usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
pid-file=/usr/local/mysql/data/mysql.pid
log-error=/usr/local/mysql/data/error.log
character_set_server=utf8
user=mysql
max_connections=1500
symbolic-links=0
!includedir /etc/my.cnf.d
四、启动服务并登陆
[root@GeekDevOps ~]# service mysqld start
Starting MySQL. SUCCESS! 
[root@GeekDevOps mysql]# ./bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21
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> 

在此过程中要求输入密码,在第三步中我们可以看到安装完成后的密码:7Eu;dsRqkY.3,输入即可登陆成功。

五、修改密码
mysql> set password=password('GeekDevOps');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye

下次登录即可使用新密码进行登录。安装过程至此结束,其他配置与我之前写的glibc版的别无二致,此处不再赘述,其他配置请在my.cnf按照自己的需求进行配置。

六、安装过程中出现的问题
  1. 在安装完成之后,查看日志我们看到:TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details)。这是一个常见问题,在配置文件/etc/my.cnf的mysqld块添加:explicit_defaults_for_timestamp=1,重启数据库服务。
  2. 在完成上一步操作的过程中,查看日志发现提示:–secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled。意思是与导出、导入有关的操作都是被禁用的,我们需要导出、导入的话就需要设置,在配置文件/etc/my.cnf中mysqld下加入:secure_file_priv=/test(目录可以按需求更改),这一项也可以在安装初始化的时候加入:–secure-file-priv=/test。
七、总结

mysql-5.7.21-el7-x86_64.tar.gz该版本的MySQL安装教程在网上并不常见,我是通过tar.gz包内的文档(/usr/local/mysql/docs/INFO_BIN)受到启发才进行安装的,从文档中我们可以看到编译的详细信息。

===== Information about the build process: =====
Build was run at 2017-12-28 05:42:32 on host 'vale08'
Build was done on  Linux-4.1.12-61.1.27.el7uek.x86_64 using x86_64
Build was done using cmake 2.8.12 
 ===== Compiler flags used (from the 'sql/' subdirectory): =====
# compile C with /bin/cc
# compile CXX with /bin/c++
C_FLAGS =  -fPIC -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -I/export/home/pb2/build/sb_0-26514852-1514435436.48/release/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/extra/rapidjson/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/release/libbinlogevents/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/libbinlogevents/export -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/sql/conn_handler -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/libbinlogevents/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/sql -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/sql/auth -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/regex -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/zlib -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/extra/yassl/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/extra/yassl/taocrypt/include -I/export/home/pb2/build/sb_0-26514852-1514435436.48/release/sql -I/export/home/pb2/build/sb_0-26514852-1514435436.48/mysql-5.7.21/extra/lz4    -DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED
C_DEFINES = -DHAVE_CONFIG_H -DHAVE_LIBEVENT1 -DHAVE_REPLICATION -DMYSQL_SERVER -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年03月14日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、准备阶段
  • 二、安装过程
  • 三、配置过程
  • 四、启动服务并登陆
  • 五、修改密码
  • 六、安装过程中出现的问题
  • 七、总结
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档