安装依赖
yum install -y libaio

下载

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -O mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
创建目录
mkdir -p /data/service/mysql

解压

tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.18-linux-glibc2.5-x86_64/* /data/service/mysql
创建用户组
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
修改权限
chown -R mysql:mysql /data/service/mysql
配置环境变量
cat <<EOF > /etc/profile.d/mysql.sh
export PATH=/data/service/mysql/bin:\$PATH
EOF
. /etc/profile
目录规划(由于mysql特殊,必须使用在/usr/local/mysql的路径才行,那么采取的方法是软链接,不建议直接安装到/usr/local/mysql的路径,迁移是个很麻烦的问题)
# 数据datadir /usr/local/mysql/data
# 参数文件my.cnf /usr/local/mysql/etc/my.cnf
# 错误日志log-error /usr/local/mysql/log/mysql_error.log
# 二进制日志log-bin /usr/local/mysql/binlogs/mysql-bin
# 慢查询日志slow_query_log_file /usr/local/mysql/log/mysql_slow_query.log
# 套接字socket文件 /usr/local/mysql/run/mysql.sock
# pid文件 /usr/local/mysql/run/mysql.pid
mkdir -p /data/service/mysql/{binlogs,log,etc,run}
mkdir -p /data/database
ln -s /data/service/mysql /usr/local/mysql
ln -s /data/database /usr/local/mysql/data
chown -R mysql.mysql /data/service/mysql/
chown -R mysql.mysql /usr/local/mysql/{data,binlogs,log,etc,run}
设置配置文件
rm -rf /etc/my.cnf #原文件是mariadb客户端留下的,不需要使用
cat <<EOF > /usr/local/mysql/etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/run/mysql.sock [mysqld]
port = 3306
socket = /usr/local/mysql/run/mysql.sock
pid_file = /usr/local/mysql/run/mysql.pid
datadir = /usr/local/mysql/data
default_storage_engine = InnoDB
max_allowed_packet = 512M
max_connections = 2048
open_files_limit = 65535 skip-name-resolve
lower_case_table_names=1 character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4' innodb_buffer_pool_size = 1024M
innodb_log_file_size = 2048M
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0 key_buffer_size = 64M log-error = /usr/local/mysql/log/mysql_error.log
log-bin = /usr/local/mysql/binlogs/mysql-bin
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/log/mysql_slow_query.log
long_query_time = 5 tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 0
query_cache_size = 0 server-id=1
EOF
初始化
mysqld --initialize --user=mysql --datadir=/data/database --basedir=/data/service/mysql
# 此时会输出临时密码,一定要记住
echo "请记住这个临时root密码!!!"
生成ssl
mysql_ssl_rsa_setup --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
设置启动项目
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
chkconfig --add mysql.server
chkconfig mysql.server on
启动
service mysql.server start
重置root密码,此时关闭
mysql_secure_installation

类似以下信息:

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: Y There are three levels of password validation policy: LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root. Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success. Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success. By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success. - Removing privileges on test database...
Success. Reloading the privilege tables will ensure that all changes
made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success. All done!

目的是:

  • 重置密码
  • 删除匿名用户
  • 关闭root用户的远程登录
  • 删除测试数据库
导入时区
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

全自动脚本:

https://github.com/easonjim/centos-shell/blob/master/mysql/install-mysql_5.7.18.sh

参考:

https://www.jianshu.com/p/0d628b2f7476(这哥们的教程算是整个网上最全的)

CentOS 7使用通过二进制包安装MySQL 5.7.18的更多相关文章

  1. 二进制包安装MySQL数据库

    1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 [ ...

  2. Linux 二进制包安装MySQL的一些问题

    第一步:安装相关的依赖yum install perl-Data-Dumper 第二步:初始化mysql数据库的内部信息./scripts/mysql_install_db --basedir=/us ...

  3. 二进制包安装Mysql

    (1).准备工作 前往mysql官网下载二进制安装包,https://dev.mysql.com/downloads/mysql/5.7.html#downloads(注意:选择操作系统时选Linux ...

  4. 二进制包安装MYSQL——

    yum install libaio -y #安装mysql依赖包tar zxf mysql-5.5.59-linux-glibc2.12-x86_64.tar.gz mv mysql-5.5.59- ...

  5. RPM包安装MySQL 5.7.18

    系统: CentOS 7 RPM包: mysql-community-client-5.7.18-1.el7.x86_64.rpm mysql-community-server-5.7.18-1.el ...

  6. MySQL二进制包安装及启动问题排查

    环境部署:VMware10.0+CentOS6.9(64位)+MySQL5.7.19(64位)一.操作系统调整 # 更改时区 .先查看时区 [root@localhost ~]# date -R Tu ...

  7. Mysql 通用二进制包安装

    通用二进制包安装 注意:这里有严格的平台问题: 使用时:centos5.5版本   (类似Windows下的绿色包) 下载(mirrors.sohu.com/mysql)   直接使用tar 解压到指 ...

  8. MySQL二进制包安装

    mysql的安装有多种方法,这里就介绍一下二进制包安装. [root@node1 ~]# tar xvf mysql-5.7.27-linux-glibc2.12-x86_64.tar [root@n ...

  9. liunx系统二进制包安装编译mysql数据库

    liunx系统二进制包安装编译mysql数据库 # 解压二进制压缩包 [root@localhost ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C ...

随机推荐

  1. ASP.net学习总结

    学习ASP.net又一次接触了B/S开发.下面先通过一张图对ASP.net有一个宏观结构的总结.之后将详细介绍ASP.net中的六大对象. 1.Request从客户端得到数据,包括基于表单的数据和通过 ...

  2. [R语言]读取文件夹下所有子文件夹中的excel文件,并根据分类合并。

    解决的问题:需要读取某个大文件夹下所有子文件夹中的excel文件,并汇总,汇总文件中需要包含的2部分的信息:1.该条数据来源于哪个子文件夹:2.该条数据来源于哪个excel文件.最终,按照子文件夹单独 ...

  3. 各浏览器 position: fixed 造成的bug 通用解决办法,Safari, iOS

    将原来使用 position: fixed  的元素外层包裹一个 div.fixedWrapper .fixedWrapper { width: 100%; overflow: hidden; pos ...

  4. JDK1.8源码hashMap

    一.概念 允许key为null,value为null:线程不安全:不保证映射的顺序:迭代 collection 视图所需的时间与 HashMap 实例的“容量”(桶的数量)及其大小(键-值映射关系数) ...

  5. ioctl函数详细说明(网络)

    ioctl 函数 本函数影响由fd 参数引用的一个打开的文件. #include<unistd.h> int ioctl( int fd, int request, .../* void ...

  6. linux服务器如何添加sudo用户

    1. 编辑 vi /etc/ssh/sshd_config 文件,修改默认端口:默认Port为22,并且已经注释掉了,修改是把注释去掉,并修改成其它的端口. 原来用默认端口:22修改为:8975 (这 ...

  7. SQLServer xp_instance_regread returned error 5,Access is denied(配置最小权限)

    公司一套智能巡检系统,客户需要最小的权限去给这套系统使用:配置完后发现很多权限报错,有一条是关于xp_instance_regread读系统注册表error 5的报错.常理error 5.是属于系统权 ...

  8. springboot自定义SpringApplication启动类

    如果默认的SpringApplication不符合你的口味,你可以创建一个本地的实例并自定义它.例如,关闭banner你可以这样写: public static void main(String[] ...

  9. 7z

    7zip是一款开源的解压缩软件,不仅自己独有的7z格式,而且支持zip,rar,tar,gzip等众多其他格式,同时7z格式的压缩比例很高,目前很多硬盘版的游戏都采用zip进行打包.下面介绍一下Lin ...

  10. Python 驱动 MongoDB 示例(PyMongo)

    Python 的MongoDB驱动 pymongo ,使用pip Install pymongo安装即可 最近发现网上的很多实例已经过时了,在此自我探究记录下来. 编写一个接口类来支持MongoDB的 ...