mysql 5.7.14二进制包安装

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
云数据库 RDS PostgreSQL,高可用系列 2核4GB
简介: 操作系统版本:[root@Darren2 ~]# cat /etc/redhat-releaseCentOS release 6.5 (Final)操作系统内核:[root@Darren2 ~]# uname -r2.

操作系统版本:

[root@Darren2 ~]# cat /etc/redhat-release

CentOS release 6.5 (Final)


操作系统内核:

[root@Darren2 ~]# uname -r

2.6.32-431.el6.x86_64


关闭防火墙并关闭自启动:

[root@Darren2 ~]# /etc/init.d/iptables stop

[root@Darren2 ~]# chkconfig --level 2345 iptables off


临时禁用selinux,并修改配置文件重启系统也禁用:

[root@Darren2 ~]# setenforce 0

[root@Darren2 ~]# vim /etc/sysconfig/selinux

SELINUX=disabled


创建目录,把mysql二进制包上传到此目录下:

[root@Darren2 ~]# mkdir -p /home/tools


切换到目录下,解压二进制包:

[root@Darren2 ~]# cd /home/tools/

[root@Darren2 tools]# tar zxf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz


创建解压包的软链接,创建软连接的目的主要是方便以后升级:

[root@Darren2 tools]# ln -s /home/tools/mysql-5.7.14-linux-glibc2.5-x86_64  /usr/local/mysql


新建用户组和用户:

[root@Darren2 local]# groupadd mysql     

[root@Darren2 local]# useradd -M -g mysql -s /sbin/nologin -d /usr/local/mysql/ mysql


创建mysql数据,日志,临时等目录,并修改所有者和所属组:

[root@Darren2 local]# mkdir -p /data/mysql/mysql3306/data /data/mysql/mysql3306/log /data/mysql/mysql3306/tmp

[root@Darren2 local]# chown -R mysql:mysql /data/mysql/mysql3306/


修改/etc/my.cnf文件,使用默认my.cnf的也可以初始化成功,不过一些文件的位置会有点乱,这里根据个人习惯修改如下:

[root@Darren2 tools]# vim /etc/my.cnf

[client]

port            = 3306

socket          = /tmp/mysql.sock

[mysql]

prompt="\\u@\\h [\\d]>"

#pager="less -i -n -S"

#tee=/opt/mysql/query.log

no-auto-rehash

[mysqld_multi]

mysqld = /usr/local/mysql/bin/mysqld_safe

mysqladmin = /usr/local/mysql/bin/mysqladmin

log = /opt/mysql/mysqld_multi.log

[mysqld]

#misc

user = mysql

basedir = /usr/local/mysql

datadir = /data/mysql/mysql3306/data

port = 3306

socket = /tmp/mysql.sock

event_scheduler = 0

tmpdir = /data/mysql/mysql3306/tmp

#timeout

interactive_timeout = 300

wait_timeout = 300

#character set

character-set-server = utf8

open_files_limit = 65535

max_connections = 100

max_connect_errors = 100000

#lower_case_table_names =1

#logs

log-output=file

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

log_warnings = 2

pid-file = mysql.pid

long_query_time = 1

#log-slow-admin-statements = 1

#log-queries-not-using-indexes = 1

log-slow-slave-statements = 1

#binlog

#binlog_format = STATEMENT

binlog_format = row

server-id = 23306

log-bin = /data/mysql/mysql3306/logs/mysql-bin

binlog_cache_size = 4M

max_binlog_size = 256M

max_binlog_cache_size = 1M

sync_binlog = 0

expire_logs_days = 10

#procedure

log_bin_trust_function_creators=1

#

gtid-mode = 0

#relay log

skip_slave_start = 1

max_relay_log_size = 128M

relay_log_purge = 1

relay_log_recovery = 1

relay-log=relay-bin

relay-log-index=relay-bin.index

log_slave_updates

#slave-skip-errors=1032,1053,1062

#skip-grant-tables

#buffers & cache

table_open_cache = 2048

table_definition_cache = 2048

table_open_cache = 2048

max_heap_table_size = 96M

sort_buffer_size = 128K

join_buffer_size = 128K

thread_cache_size = 200

query_cache_size = 0

query_cache_type = 0

query_cache_limit = 256K

query_cache_min_res_unit = 512

thread_stack = 192K

tmp_table_size = 96M

key_buffer_size = 8M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

bulk_insert_buffer_size = 32M

#myisam

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

#innodb

innodb_buffer_pool_size = 100M

innodb_buffer_pool_instances = 1

innodb_data_file_path = ibdata1:100M:autoextend

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 8M

innodb_log_file_size = 100M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 50

innodb_file_per_table = 1

innodb_rollback_on_timeout

innodb_status_file = 1

innodb_io_capacity = 2000

transaction_isolation = READ-COMMITTED

innodb_flush_method = O_DIRECT


数据库初始化,默认是带密码的,也可以指定参数--initialize-insecure则不需要密码

[root@Darren2 data]# cd /usr/local/mysql/bin/   

[root@Darren2 bin]# ./mysqld --initialize --user=mysql


查看密码:

[root@Darren2 data]# cat /data/mysql/mysql3306/data/error.log |grep password

2016-11-17T13:29:25.055578Z 1 [Note] A temporary password is generated for root@localhost: XgqTE9Cb+rLc


复制启动脚本并改名为mysql:

[root@Darren2 init.d]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql


启动mysql服务,并加入自启动中:

[root@Darren2 init.d]# /etc/init.d/mysql start

[root@Darren1 ~]# chkconfig --add mysql


执行命令加入环境变量:

echo 'export PATH=$PATH:/usr/local/mysql/bin/'>>/etc/profile

[root@Darren2 init.d]# source /etc/profile

[root@Darren2 init.d]# mysql -S /tmp/mysql.sock -p

Enter password:   --写入上面查看到的密码


立即修改用户密码:

unknown)@localhost [(none)]>alter user user() identified by '147258';


查看数据库账号,5.7中user表中账号比较安全,不需要账号安全加固,即不需要删除无用账号

root@localhost [(none)]>select user,host from mysql.user;

+-----------+-----------+

| user      | host      |

+-----------+-----------+

| mysql.sys | localhost |

| root      | localhost |

+-----------+-----------+


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
An工具介绍之宽度工具、变形工具与套索工具
An工具介绍之宽度工具、变形工具与套索工具
2114 0
An工具介绍之宽度工具、变形工具与套索工具
|
Linux Android开发 iOS开发
建议收藏!8款音乐APP,找不到喜欢的,算我输!
最近一段时间,有不少同学反复询问我音乐相关的软件。 在以前的文章中,我先后介绍过很多音乐相关的APP,其中不乏一时之间让我非常惊艳的。
建议收藏!8款音乐APP,找不到喜欢的,算我输!
GDPR的发展历程
【10月更文挑战第7天】GDPR的发展历程
680 7
|
自动驾驶 物联网 5G
标题:5G频段解析:低频、中频与毫米波的奥秘
标题:5G频段解析:低频、中频与毫米波的奥秘
1365 65
|
人工智能 监控 安全
安全和鲁棒性
安全和鲁棒性
324 0
|
数据可视化 搜索推荐 BI
哪些任务进度管理器值得推荐?几款工具使用测评
在快节奏的工作环境中,任务进度管理器成为提高效率和协作的关键工具。本文介绍了三款高效实用的管理软件:板栗看板、Trello 和 Asana。这些工具不仅帮助用户更好地规划和跟踪项目进度,还能确保任务按时完成。板栗看板以其直观的看板和灵活的自定义选项受到青睐;Trello 通过丰富的插件和跨平台支持,成为全球广泛使用的工具;Asana 则以强大的功能和灵活的工作流管理,适合大型企业和复杂项目的管理需求。用户可根据自身需求选择合适的工具,提高团队协作效率,达成项目目标。
|
监控 安全 物联网
智能家居系统的安全与隐私保护技术
随着物联网技术的飞速发展,智能家居系统逐渐进入千家万户。然而,随之而来的安全与隐私问题亦日益凸显。本文将探讨智能家居系统中存在的安全风险,分析当前采用的主要安全技术措施,并指出用户在享受智能生活时需注意的隐私保护策略。通过深入浅出的方式,旨在增强大众对智能家居安全的认识,并提供实用的保护建议。
|
安全 网络安全 数据库
信息安全十大原则
【2月更文挑战第29天】该文提出了保障信息安全的十大关键原则.
|
缓存 调度 芯片
同步多线程
<div id="card-container" class="mod-top" style="clear:both"> <div class="card-summary nslog-area clearfix"> <div class="card-summary-content"> <div class="para">同步多线程(SMT)是一种在一个CPU 的<a target="
1937 0