经常听说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=
[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=
general_log_file="MicroWin10-1535.log"
slow-query-log=
slow_query_log_file="MicroWin10-1535-slow.log"
long_query_time= # Binary Logging.
log-error="MicroWin10-1535.err" # Server Id.
server-id= # Secure File Priv.
secure-file-priv="G:\mysql572\Uploads" max_connections=
query_cache_size= table_open_cache= tmp_table_size=34M thread_cache_size= 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 , 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 or to reduce disk I/O to the
# logs. Value means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value
# 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= # 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 % 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 -.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 %-% 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= # The increment size (in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
innodb_autoextend_increment= # 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= # Determines the number of threads that can enter InnoDB concurrently.
innodb_concurrency_tickets= # 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= # It specifies the maximum number of .ibd files that MySQL can keep open at one time. The minimum value is .
innodb_open_files= # When this variable is enabled, InnoDB updates statistics during metadata statements.
innodb_stats_on_metadata= # When innodb_file_per_table is enabled (the default in 5.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= back_log= flush_time= join_buffer_size=256K max_allowed_packet=4M max_connect_errors= open_files_limit= query_cache_type= sort_buffer_size=256K table_definition_cache= binlog_row_event_max_size=8K sync_master_info= sync_relay_log= sync_relay_log_info=

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

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

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

C:\Users\liqiang>tasklist |findstr mysql
mysqld.exe Services , K
mysqld.exe Console , K
mysql.exe Console , K C:\Users\liqiang>netstat -ano | findstr
TCP 0.0.0.0: 0.0.0.0: LISTENING
TCP [::]: [::]: LISTENING
TCP [::]: [::]: ESTABLISHED
TCP [::]: [::]: ESTABLISHED

连接上面启动的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
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , 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-.err |
+---------------+-----------------------+
row in set, warning (0.01 sec) mysql> show variables like 'datadir';
+---------------+-------------------+
| Variable_name | Value |
+---------------+-------------------+
| datadir | G:\mysql572\Data\ |
+---------------+-------------------+
row in set, 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 : WIN32_OWN_PROCESS
START_TYPE : AUTO_START
ERROR_CONTROL : NORMAL
BINARY_PATH_NAME : G:\mysql572\bin\mysqld --defaults-file=G:\mysql572\
my.ini mysql572
LOAD_ORDER_GROUP :
TAG :
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%'

mysql集成部署的更多相关文章

  1. Centos7.4简单安装使用gitlab+maven+jenkins实现java代码的持续集成部署

    1.工具的简单介绍 gitlab--源代码版本管理控制工具 maven--java代码编译构建工具 jenkins--基于java开发的自动化持续集成部署工具 sonar--代码质量管理工具 2.gi ...

  2. 自动化集成部署udeployer 批量统一安装一键部署

    通过jenkins构建项目:version版本控制:udployer自动化集成:ucop业务巡检做到高效高可用的自动化体系.   1.0版本: 逻辑与业务分离,完美实现逻辑与业务分离,业务实现统一sh ...

  3. Ubuntu14.04 Django Mysql安装部署全过程

    Ubuntu14.04 Django Mysql安装部署全过程   一.简要步骤.(阿里云Ubuntu14.04) Python安装 Django Mysql的安装与配置 记录一下我的部署过程,也方便 ...

  4. Apache+PHP+Mysql 集成环境 几个软件pk

    WampServer 2.5 64位 - 工具软件 - 源码之家 2014年8月25日 - WampServer是Apache+PHP+Mysql 集成环境,拥有简单的图形和菜单安装和配置环境.支持2 ...

  5. 【转】Nginx+php-fpm+MySQL分离部署详解

    转:http://www.linuxidc.com/Linux/2015-07/120580.htm Nginx+php-fpm+MySQL分离部署详解 [日期:2015-07-26] 来源:Linu ...

  6. ABP .Net Core API和Angular前端APP集成部署

    前言:在ABP官网(https://aspnetboilerplate.com)生成的.Net Core + Angular项目前后端是两个独立的项目,我们可以分开部署,也可以将前端和Web API一 ...

  7. [dotnet core]落地微服务特色的DevOps管道,持续集成/部署到kubernetes。

    目录 前言 目标 工具 - 最小的学习成本 方案 - 愿景 1. 持续集成 - CI 2. 持续部署 - CD 部署环境 1. 部署gitlab-runner 2. 注册gitlab-runner 搭 ...

  8. [转]Infobright是一个与MySQL集成的开源数据仓库

    [文章作者:张宴 本文版本:v1.1 最后修改:2010.05.18 转载请注明原文链接:http://blog.zyan.cc/infobright/] Infobright是一个与MySQL集成的 ...

  9. MySQL安装部署

    MySQL安装部署 使用自动化脚本

随机推荐

  1. 《在kali上完成gdb调试》

    kali使用流程 1.使menuos停止 方法如图: 效果如图: 2.启动调试 打开一个新的命令行,然后方法如下图: 3.设置断点 注:由图可看出,断点设置在sys_clone,dup_task_st ...

  2. ios UnitTest 学习笔记

    一.运行第一个单元测试: 1.在Xcode 5中新建一个工程默认自带一个单元测试的文件夹,IDE自动生成了一个实现XCTestCase的.m文件,里面有一个失败测试(早期版本中实现的是SenTestC ...

  3. alpha阶段的 postmortem 报告

    1. 每个成员到了第二次alpha 阶段与第一次相比,取得什么进步? 成员    黄杰 学会了app环境的搭建和代码的基本理解 李炫宗 更加明白安卓代码的编写和理解 康取 对安卓界面的设计有一些了解 ...

  4. winform只允许一个应用程序运行

    使用互斥体Mutex类型 using System.Threading; //声明互斥体 Mutex mutex = new Mutex(false, "ThisShouldOnlyRunO ...

  5. .net 开源组件推荐 之 StackExchange

    已经两年没更新过博客了!!! StackExchange,地址:https://github.com/StackExchange,开源的这些项目都是在StackOverflow线上使用的. 说起Sta ...

  6. Tomcat下bootstrap启动分析

    "C:\Program Files\Java\jdk1.7.0\bin\javaw.exe" -agentlib:jdwp=transport=dt_socket,suspend= ...

  7. [转帖] wordpress 的安装过程

    https://blog.csdn.net/qq_34364668/article/details/78116473 下载Wordpress wget http://wordpress.org/lat ...

  8. WM_CONCAT和LISTAGG 语法例子

    select to_char(replace(wm_concat(name), ',', '')) from codeitems where setid = 'A018' and ' like cod ...

  9. 【设计模式】—— 享元模式Flyweight

    前言:[模式总览]——————————by xingoo 模式意图 享元模式,也叫[轻量级模式]或者[蝇量级模式].主要目的就是为了减少细粒度资源的消耗.比如,一个编辑器用到大量的字母数字和符号,但是 ...

  10. BZOJ1492 货币兑换 CDQ分治优化DP

    1492: [NOI2007]货币兑换Cash Time Limit: 5 Sec  Memory Limit: 64 MB Description 小Y最近在一家金券交易所工作.该金券交易所只发行交 ...