热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

开发笔记:mysql集成部署

篇首语:本文由编程笔记#小编为大家整理,主要介绍了mysql集成部署相关的知识,希望对你有一定的参考价值。经常听说

篇首语:本文由编程笔记#小编为大家整理,主要介绍了mysql集成部署相关的知识,希望对你有一定的参考价值。



  

 经常听说mysql数据库是集成在系统中,也一直不太明白集成的概念。今天才明白集成的概念就是将mysql所有的文件放到一个文件夹下放到系统中,也就是将mysql采用目录迁移部署的方式进行安装。在上一篇研究了mysql的数据存储结构之后,也研究了mysql作为目录部署以及安装为mysql服务的方法。

 


1.mysql目录安装

  mysql目录安装也就是将mysql必须的一些文件放到一起,然后通过配置文件的配置即可实现。

  mysql主要的目录也就是data目录以及bin(存mysql的可执行文件)、lib(存放mysql的dll库)、share(存放mysql的语言支持库)、uploads(一般作为mysql的导出目录)、my.ini(mysql的端口以及其他全局配置文件)。

  例如我的目录安装的一个目录:

 

   bin、lib、share、Uploads是直接从mysql5.7的安装目录下拷贝过来的,Data目录也是拷贝的,上篇文章已经讲解过Data目录下存放具体的Mysql的数据库以及表结构与表数据,查看Data的目录如下(是在原来的数据库迁移古来,所以如果集成部署成功数据库应该与原来一样):

 

my.ini文件:(注意标红位置的修改)


[client]
no
-beep
port
=3307
[mysql]
default-character-set=utf8
# server_type
=3
[mysqld]
# The TCP
/IP Port the MySQL Server will listen on
port
=3307
# Path to installation directory. All paths are usually resolved relative to
this.
# basedir
="C:/Program Files/MySQL/MySQL Server 5.7/"
# Path to the database root
datadir
=G:\\mysql572\\Data
# The
default character set that will be used when a new schema or table is
# created and no character
set is defined
character
-set-server=utf8
# The
default storage engine that will be used when create new tables when
default-storage-engine=INNODB
# Set the SQL mode to strict
sql
-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
# Enable Windows Authentication
# plugin
-load=authentication_windows.dll
# General and Slow logging.
log
-output=FILE
general
-log=0
general_log_file
="MicroWin10-1535.log"
slow
-query-log=1
slow_query_log_file
="MicroWin10-1535-slow.log"
long_query_time
=10
# Binary Logging.
log
-error="MicroWin10-1535.err"
# Server Id.
server
-id=1
# Secure File Priv.
secure
-file-priv="G:\\mysql572\\Uploads"
max_connections
=151
query_cache_size
=0
table_open_cache
=2000
tmp_table_size
=34M
thread_cache_size
=10
myisam_max_sort_file_size
=100G
myisam_sort_buffer_size
=60M
key_buffer_size
=8M
read_buffer_size
=64K
read_rnd_buffer_size
=256K
#
*** INNODB Specific options ***
# innodb_data_home_dir
=0.0
# Use
this option if you have a MySQL server with InnoDB support enabled
# but you
do not plan to use it. This will save memory and disk space
# and speed up some things.
# skip
-innodb
# If
set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise
this safety, and you are running small
# transactions, you may
set this to 0 or 2 to reduce disk I/O to the
# logs. Value
0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value
2
# means the log
is written to the log file at each commit, but the log
# file
is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit
=1
# The size of the buffer InnoDB uses
for buffering log data. As soon as
# it
is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with
long transactions).
innodb_log_buffer_size
=1M
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you
set this the less disk I/O is needed to
# access data
in tables. On a dedicated database server you may set this
# parameter up to
80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging
in the operating system. Note that on 32bit systems you
# might be limited to
2-3.5G of user level memory per process, so do not
#
set it too high.
innodb_buffer_pool_size
=8M
# Size of each log file
in a log group. You should set the combined size
# of log files to about
25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed
for the
# recovery process.
innodb_log_file_size
=48M
# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware
as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency
=9
# The increment size (
in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
innodb_autoextend_increment
=64
# The number of regions that the InnoDB buffer pool
is divided into.
# For systems with buffer pools
in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency,
# by reducing contention
as different threads read and write to cached pages.
innodb_buffer_pool_instances
=8
# Determines the number of threads that can enter InnoDB concurrently.
innodb_concurrency_tickets
=5000
# Specifies how
long in milliseconds (ms) a block inserted into the old sublist must stay there after its first access before
# it can be moved to the
new sublist.
innodb_old_blocks_time
=1000
# It specifies the maximum number of .ibd files that MySQL can keep open at one time. The minimum value
is 10.
innodb_open_files
=300
# When
this variable is enabled, InnoDB updates statistics during metadata statements.
innodb_stats_on_metadata
=0
# When innodb_file_per_table
is enabled (the default in 5.6.6 and higher), InnoDB stores the data and indexes for each newly created table
#
in a separate .ibd file, rather than in the system tablespace.
innodb_file_per_table
=1
innodb_checksum_algorithm
=0
back_log
=80
flush_time
=0
join_buffer_size
=256K
max_allowed_packet
=4M
max_connect_errors
=100
open_files_limit
=4161
query_cache_type
=0
sort_buffer_size
=256K
table_definition_cache
=1400
binlog_row_event_max_size
=8K
sync_master_info
=10000
sync_relay_log
=10000
sync_relay_log_info
=10000

 


2.启动上面的mysql并且进行连接


G:\\mysql572\\bin>mysqld --defaults-file=G:\\mysql572\\my.ini

 

新开cmd窗口查看进程信息:


C:\\Users\\liqiang>tasklist |findstr mysql
mysqld.exe
1912 Services 0 228,348 K
mysqld.exe
325752 Console 9 208,488 K
mysql.exe
325984 Console 9 5,328 K
C:\\Users\\liqiang
>netstat -ano | findstr 3307
TCP
0.0.0.0:3307 0.0.0.0:0 LISTENING 325752
TCP [::]:
3307 [::]:0 LISTENING 325752
TCP [::
1]:3307 [::1]:61234 ESTABLISHED 325752
TCP [::
1]:61234 [::1]:3307 ESTABLISHED 325984

 

连接上面启动的3307端口的mysql:


C:\\Users\\liqiang>mysql -uroot -p -P3307
Enter password:
******
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection
id is 2
Server version:
5.7.10-log MySQL Community Server (GPL)
Copyright (c)
2000, 2015, 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
> show variables like \'log_error\';
+---------------+-----------------------+
| Variable_name | Value |
+---------------+-----------------------+
| log_error | .\\MicroWin10-1535.err |
+---------------+-----------------------+
1 row in set, 1 warning (0.01 sec)
mysql
> show variables like \'datadir\';
+---------------+-------------------+
| Variable_name | Value |
+---------------+-------------------+
| datadir | G:\\mysql572\\Data\\ |
+---------------+-------------------+
1 row in set, 1 warning (0.00 sec)

 


3.将上面目录安装的mysql安装为windows服务

需以管理员身份执行cmd


C:\\Windows\\system32>G:\\mysql572\\bin\\mysqld --install mysql572 --defaults-file="G:\\mysql572\\my.ini"
Service successfully installed.

 

查看上面安装的服务:


C:\\Windows\\system32>sc qc mysql572
[SC] QueryServiceConfig 成功
SERVICE_NAME: mysql572
TYPE :
10 WIN32_OWN_PROCESS
START_TYPE :
2 AUTO_START
ERROR_CONTROL :
1 NORMAL
BINARY_PATH_NAME : G:\\mysql572\\bin\\mysqld
--defaults-file=G:\\mysql572\\
my.ini mysql572
LOAD_ORDER_GROUP :
TAG :
0
DISPLAY_NAME : mysql572
DEPENDENCIES :
SERVICE_START_NAME : LocalSystem

 

   安装成功之后即可像正常的服务一样使用,启动可以用sc start mysql

 

删除服务也与平时删除服务一样:


sc delete mysql572
或者采用mysqld方式移除系统服务

mysqld
--remove MySQL57

 

   至此mysql集成安装完成,在实际的项目中我们可以采用这种方式将mysql嵌入到系统中进行部署安装。至于my.ini的配置在需要啥全局变量设置的时候在这里设置。

补充:查看mysql数据目录可以查看全局参数datadir 


show global variables like \'%datadir%\'



推荐阅读
  • Unity与MySQL连接过程中出现的新挑战及解决方案探析 ... [详细]
  • 本文介绍了如何利用Shell脚本高效地部署MHA(MySQL High Availability)高可用集群。通过详细的脚本编写和配置示例,展示了自动化部署过程中的关键步骤和注意事项。该方法不仅简化了集群的部署流程,还提高了系统的稳定性和可用性。 ... [详细]
  • 本文详细介绍了在Linux系统上编译安装MySQL 5.5源码的步骤。首先,通过Yum安装必要的依赖软件包,如GCC、GCC-C++等,确保编译环境的完备。接着,下载并解压MySQL 5.5的源码包,配置编译选项,进行编译和安装。最后,完成安装后,进行基本的配置和启动测试,确保MySQL服务正常运行。 ... [详细]
  • PTArchiver工作原理详解与应用分析
    PTArchiver工作原理及其应用分析本文详细解析了PTArchiver的工作机制,探讨了其在数据归档和管理中的应用。PTArchiver通过高效的压缩算法和灵活的存储策略,实现了对大规模数据的高效管理和长期保存。文章还介绍了其在企业级数据备份、历史数据迁移等场景中的实际应用案例,为用户提供了实用的操作建议和技术支持。 ... [详细]
  • 在Linux系统中避免安装MySQL的简易指南
    在Linux系统中避免安装MySQL的简易指南 ... [详细]
  • Amoeba 通过优化 MySQL 的读写分离功能显著提升了数据库性能。作为一款基于 MySQL 协议的代理工具,Amoeba 能够高效地处理应用程序的请求,并根据预设的规则将 SQL 请求智能地分配到不同的数据库实例,从而实现负载均衡和高可用性。该方案不仅提高了系统的并发处理能力,还有效减少了主数据库的负担,确保了数据的一致性和可靠性。 ... [详细]
  • SecureCRT是一款功能强大的终端仿真软件,支持SSH1和SSH2协议,适用于在Windows环境下高效连接和管理Linux服务器。该工具不仅提供了稳定的连接性能,还具备丰富的配置选项,能够满足不同用户的需求。通过SecureCRT,用户可以轻松实现对远程Linux系统的安全访问和操作。 ... [详细]
  • 本文详细介绍了在CentOS 6.5 64位系统上使用阿里云ECS服务器搭建LAMP环境的具体步骤。首先,通过PuTTY工具实现远程连接至服务器。接着,检查当前系统的磁盘空间使用情况,确保有足够的空间进行后续操作,可使用 `df` 命令进行查看。此外,文章还涵盖了安装和配置Apache、MySQL和PHP的相关步骤,以及常见问题的解决方法,帮助用户顺利完成LAMP环境的搭建。 ... [详细]
  • 本文深入探讨了NoSQL数据库的四大主要类型:键值对存储、文档存储、列式存储和图数据库。NoSQL(Not Only SQL)是指一系列非关系型数据库系统,它们不依赖于固定模式的数据存储方式,能够灵活处理大规模、高并发的数据需求。键值对存储适用于简单的数据结构;文档存储支持复杂的数据对象;列式存储优化了大数据量的读写性能;而图数据库则擅长处理复杂的关系网络。每种类型的NoSQL数据库都有其独特的优势和应用场景,本文将详细分析它们的特点及应用实例。 ... [详细]
  • 如何优化MySQL数据库性能以提升查询效率和系统稳定性 ... [详细]
  • PHP预处理常量详解:如何定义与使用常量 ... [详细]
  • 本文介绍了如何利用 Delphi 中的 IdTCPServer 和 IdTCPClient 控件实现高效的文件传输。这些控件在默认情况下采用阻塞模式,并且服务器端已经集成了多线程处理,能够支持任意大小的文件传输,无需担心数据包大小的限制。与传统的 ClientSocket 相比,Indy 控件提供了更为简洁和可靠的解决方案,特别适用于开发高性能的网络文件传输应用程序。 ... [详细]
  • 本指南详细介绍了在Linux环境中高效连接MySQL数据库的方法。用户可以通过安装并使用`mysql`客户端工具来实现本地连接,具体命令为:`mysql -u 用户名 -p 密码 -h 主机`。例如,使用管理员账户连接本地MySQL服务器的命令为:`mysql -u root -p pass`。此外,还提供了多种配置优化建议,以确保连接过程更加稳定和高效。 ... [详细]
  • 在CICS应用环境中,众多客户端通过网络与CICS服务器进行连接。系统管理员可以通过CICS系统交易CEMT查询当前连接的客户端信息。然而,在非客户端模式下,识别用户连接并解决信息获取错误的问题变得更为复杂。本文将探讨如何在CICS服务器端准确识别非客户端模式的用户连接,并提供有效的解决方案,以确保系统的稳定性和数据的准确性。此外,还将介绍一些常用的诊断工具和技术,帮助管理员快速定位和解决问题。 ... [详细]
  • Presto:高效即席查询引擎的深度解析与应用
    本文深入解析了Presto这一高效的即席查询引擎,详细探讨了其架构设计及其优缺点。Presto通过内存到内存的数据处理方式,显著提升了查询性能,相比传统的MapReduce查询,不仅减少了数据传输的延迟,还提高了查询的准确性和效率。然而,Presto在大规模数据处理和容错机制方面仍存在一定的局限性。本文还介绍了Presto在实际应用中的多种场景,展示了其在大数据分析领域的强大潜力。 ... [详细]
author-avatar
漫路细雨中_575
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有