MySQL5.6单机部署安装

MySQL二进制包安装:

  1. 安装包获取方式

    官网下载url: http://dev.mysql.com/downloads/mysql/

    数据库下载url:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22-linuxglibc2.5-x86_64.tar.gz

    搜狐下载mirror : http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.22-linux-glibc2.5x86_64.tar.gz

  2. 数据库规划

    安装场景
    操作系统 Red Hat Enterprise Linux Server release 6.8 (Santiago)

    数据库版本  mysql-5.6.22-linux-glibc2.5-x86_64
    IP地址 192.168.1.100/24 
    数据库安装目录 /usr/local/mysql
    数据库数据文件目录 /data/mysql/mysql_3306

  3. 安装步骤

  • 关闭相关服务

[[email protected] ~]# getenforce
Enforcing
[[email protected] ~]# setenforce 0                    >临时关闭,永久关闭可修改配置文件
[[email protected] ~]# getenforce
Permissive
[[email protected] ~]# cat /etc/selinux/config | grep -v ^# | grep -v ^$
SELINUX=disabled
SELINUXTYPE=targeted
 [[email protected] ~]# /etc/init.d/iptables stop
[[email protected] ~]# chkconfig iptables off
  • 目录结构:

# mkdir -p /opt/{software,mysql}
# tree /opt/
├── mysql
└── software
  • 上传MySQL安装包

  • 解压MySQL安装包

[[email protected] software]# ls
mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[[email protected] software]# tar -zxf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[[email protected] software]# ls
mysql-5.6.39-linux-glibc2.12-x86_64 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[[email protected] software]# mv mysql-5.6.22-linux-glibc2.5-x86_64 /opt/mysql/mysql5.6
[[email protected] software]# cd ..
[[email protected] opt]# cd mysql/
[[email protected] mysql]# ls
mysql5.6
  • 安装MySQL

[[email protected] software]# cd /usr/local/
[[email protected] local]# ln -s /opt/mysql/mysql5.6 mysql
[[email protected] local]# ls -l mysql
lrwxrwxrwx. 1 root root 19 Jan 13 19:51 mysql -> /opt/mysql/mysql5.6
  • 创建MySQL用户

[[email protected] data]# mkdir -p /data/mysql/mysql_3306/{data,tmp}
[[email protected] data]# tree /data
/data
└── mysql
    └── mytest_3306
[[email protected] home]# groupadd mysql                             > 创建mysql组
[[email protected] home]# useradd mysql -g mysql -d /data/mysql/mytest_3306 -s /dev/null                         >新建的 mysql 用户,属组mysql ,homedir 是 /data/mysql/mytest_3306,登录shell为空
  • 创建配置文件

    /etc/my.cnf 为MySQL数据库配置文件

#my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock

[mysql]
prompt="\\[email protected]\\h:\p \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql_3306/data/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/mytest_3306
port = 3306
socket = /tmp/mysql.sock
event_scheduler = 0

#timeout
interactive_timeout = 300
wait_timeout = 300

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000

skip-name-resolve = 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 = mixed
server-id = 203306
log-bin = mybinlog
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10

#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062

explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
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:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
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

#端口号为3306的实例特殊配置
[mysqld3306]
port =3306
server-id=203306
#指定本实例相应版本的basedir和datadir
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3306/data
socket = /tmp/mysql_3306.sock
#重新配置这几个选项,不与全局配置一样,会直接覆盖上面的全局设置
innodb_buffer_pool_size = 100m
#transaction_isolation = REPEATABLE-READ

[mysqld3308]
port=3308
server-id=203308
#binlog-do-db=db01
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3308/data
socket = /tmp/mysql_3308.sock
#重新配置这几个选项,不与全局配置一样,会直接覆盖上面的全局设置
innodb_buffer_pool_size = 100m
innodb_flush_log_at_trx_commit = 2
sync_binlog = 0

[mysqld3309]
port=3309
server-id=203309
#binlog-do-db=db01
basedir= /usr/local/mysql
datadir = /data/mysql/mysql_3309/data
socket = /tmp/mysql_3309.sock
#重新配置这几个选项,不与全局配置一样,会直接覆盖上面的全局设置
innodb_buffer_pool_size = 100m
innodb_flush_log_at_trx_commit = 2
sync_binlog = 0
  • 精简my.cnf配置

#my.cnf
[client]
port = 3306
socket = /data/mysql/mysql_3306/tmp/mysql.sock
[mysql]
prompt="\\[email protected]\\h:\p \\R:\\m:\\s [\\d]:"
#tee=/data/mysql/mysql_3306/data/query.log
no-auto-rehash
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql_3306/data
port = 3306
socket = /data/mysql/mysql_3306/tmp/mysql.sock
event_scheduler = 0
#timeout
interactive_timeout = 300
wait_timeout = 300
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
skip-name-resolve = 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 = mixed
server-id = 203306
log-bin = /data/mysql/mysql_3306/mybinlog
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10
#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062
explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
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:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
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
[mysqld_safe]
open_file_limit = 65535
  • 初始化MySQL数据库datadir

[[email protected] home]# chown -R mysql.mysql /data/mysql/mysql_3306                >修改属主属组
[[email protected] home]# cd /usr/local/mysql/
[[email protected] mysql]# chown -R mysql.mysql /usr/local/mysql/*
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/mysql_3306/data
Installing MySQL system tables...OK

Filling help tables...OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password ‘new-password‘
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password ‘new-password‘

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
  • 添加环境变量

[[email protected] mysql]# echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
[[email protected] mysql]# source /etc/profile
  • 启动服务配置

[[email protected] mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.......... SUCCESS!
[[email protected] ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.39-log MySQL Community Server (GPL)
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.
[email protected]:mysql.sock 15:02:46 [(none)]show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

原文地址:https://www.cnblogs.com/caiyuanzidi/p/8990772.html

时间: 2024-10-22 16:40:31

MySQL5.6单机部署安装的相关文章

Hadoop 2.2.0部署安装(笔记,单机安装)

SSH无密安装与配置 具体配置步骤: ◎ 在root根目录下创建.ssh目录 (必须root用户登录) cd /root & mkdir .ssh chmod 700 .ssh & cd .ssh ◎ 创建密码为空的 RSA 密钥对: ssh-keygen -t rsa -P "" ◎ 在提示的对称密钥名称中输入 id_rsa将公钥添加至 authorized_keys 中: cat id_rsa.pub >> authorized_keys chmod 6

Spark-1.4.0单机部署(Hadoop-2.6.0采用伪分布式)【已测】

??目前手上只有一个机器,就先拿来练下手(事先服务器上没有安装软件)尝试一下Spark的单机部署. ??几个参数: ??JDK-1.7+ ??Hadoop-2.6.0(伪分布式): ??Scala-2.10.5: ??Spark-1.4.0: ??下面是具体的配置过程 安装JDK 1.7+ [下载网址]http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 环境变量设置(最好不要采用o

如何批量部署Office 2013 (三)——单机部署Office 2013

接下来我们来看Office的部署方法,首先来看单机环境下的 1.将Office 2013安装文件复制到网络存储位置 2.将制作好的OCT文件拷贝到updates文件夹下 3.在客户端计算机中打开命令提示符 4.客户端计算机中此前已经安装了Office 2010 5.在命令提示符中输入pushd \\192.168.8.14\storehouse\Office Deployment\ 6.输入setup回车 7.部署过程已经开始,因为是无人参与并且无提示的部署,所以在操作界面中只会看到Office

vCenter Server6.5 & SQL Server2014单机部署 - vShpere ESXI6.0-6.5集群管理

vCenter Server6.5 & SQL Server2014单机部署 VMware官方网站提供免费下载vCenter Server6.5试用版: http://www.vmware.com/ 系统版本:Windows Server2012 R2 部署vCenter Server6.5 步骤: 1.安装SQL Server2014 SP2(或者SQL Server2008R2 SP1以上) 2.配置ODBC 64位数据源 3.安装vCenter Server6.5 (VMware-VIM-

Hadoop单机模式安装-(2)安装Ubuntu虚拟机

网络上关于如何单机模式安装Hadoop的文章很多,按照其步骤走下来多数都失败,按照其操作弯路走过了不少但终究还是把问题都解决了,所以顺便自己详细记录下完整的安装过程. 此篇主要介绍在虚拟机设置完毕后,如何进行Ubuntu的安装. 我所记录的笔记适合没有Linux基础的朋友跟我一起操作,同时欢迎高手参观指导. 环境约定 以下环境基于攥写时间:5th July 2015. 宿主机器:Windows 8 虚拟机环境:WMware Wrokstation 11 Ubuntu版本:Ubuntu Deskt

linux 之休验(JDK7+Tomcat7+MySQL5.5)部署环境

------------------------------------------------------------------------------------------------------------------ JDK 0:下载JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 1:卸载(root用户) 1.0:查询已安装的jdk # rpm -qa|gr

RocketMQ 消息队列单机部署及使用

转载请注明来源:http://blog.csdn.net/loongshawn/article/details/51086876 相关文章: <RocketMQ 消息队列单机部署及使用> < java编写简单消息队列.实现高德坐标变形服务> 0 RocketMQ简单介绍 0.1 介绍 RocketMQ是一个消息中间件. 消息中间件中有两个角色:消息生产者和消息消费者.RocketMQ里相同有这两个概念.消息生产者负责创建消息并发送到RocketMQ服务器.RocketMQ服务器会将

openstack swift 源码分析之swift单机部署

本文对在单机部署swift 其中每一个细节做详细的介绍,并对配置做相应的解释 PC物理机    Ubuntu-12.04-desktop-64位 Swift 版本:1.13.1 Swift-client   1.2.0 注意:本文所有操作都是在root权限下进行的. 1 .下载swift 和swift-client 源代码,本文利用git从github获取其源代码 获取swift源代码 git clone https://github.com/openstack/swift.git 获取pyth

ETL作业调度软件TASKCTL4.1单机部署

单机部署,实际上就是将EM节点和一个Server节点安装到同一个地方.EM节点是TASKCTL服务端的最顶层,主要负责客户端与服务端之间的通信.Server节点是TASKCTL的调度服务控制层,也有Agent节点的部分功能,能够直接执行任务.下面我们来看看单机部署的过程. 先释放tar包的文件 tar vxf taskctlforlinux32_4.1.3.tar1 在安装之前,我们需要先设置好环境变量,请注意,这里是分别安装到同一台服务器的不同账户下,所以只需要在root账户下设置一次环境变量