经常听说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文件:(注意标红位置的修改)

  1. [client]
  2. no-beep
  3. port=3307
  4.  
  5. [mysql]
  6.  
  7. default-character-set=utf8
  8.  
  9. # server_type=
  10. [mysqld]
  11. # The TCP/IP Port the MySQL Server will listen on
  12. port=3307
  13.  
  14. # Path to installation directory. All paths are usually resolved relative to this.
  15. # basedir="C:/Program Files/MySQL/MySQL Server 5.7/"
  16.  
  17. # Path to the database root
  18. datadir=G:\mysql572\Data
  19.  
  20. # The default character set that will be used when a new schema or table is
  21. # created and no character set is defined
  22. character-set-server=utf8
  23.  
  24. # The default storage engine that will be used when create new tables when
  25. default-storage-engine=INNODB
  26.  
  27. # Set the SQL mode to strict
  28. sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  29.  
  30. # Enable Windows Authentication
  31. # plugin-load=authentication_windows.dll
  32.  
  33. # General and Slow logging.
  34. log-output=FILE
  35. general-log=
  36. general_log_file="MicroWin10-1535.log"
  37. slow-query-log=
  38. slow_query_log_file="MicroWin10-1535-slow.log"
  39. long_query_time=
  40.  
  41. # Binary Logging.
  42. log-error="MicroWin10-1535.err"
  43.  
  44. # Server Id.
  45. server-id=
  46.  
  47. # Secure File Priv.
  48. secure-file-priv="G:\mysql572\Uploads"
  49.  
  50. max_connections=
  51. query_cache_size=
  52.  
  53. table_open_cache=
  54.  
  55. tmp_table_size=34M
  56.  
  57. thread_cache_size=
  58.  
  59. myisam_max_sort_file_size=100G
  60.  
  61. myisam_sort_buffer_size=60M
  62.  
  63. key_buffer_size=8M
  64.  
  65. read_buffer_size=64K
  66. read_rnd_buffer_size=256K
  67.  
  68. #*** INNODB Specific options ***
  69. # innodb_data_home_dir=0.0
  70.  
  71. # Use this option if you have a MySQL server with InnoDB support enabled
  72. # but you do not plan to use it. This will save memory and disk space
  73. # and speed up some things.
  74. # skip-innodb
  75.  
  76. # If set to , InnoDB will flush (fsync) the transaction logs to the
  77. # disk at each commit, which offers full ACID behavior. If you are
  78. # willing to compromise this safety, and you are running small
  79. # transactions, you may set this to or to reduce disk I/O to the
  80. # logs. Value means that the log is only written to the log file and
  81. # the log file flushed to disk approximately once per second. Value
  82. # means the log is written to the log file at each commit, but the log
  83. # file is only flushed to disk approximately once per second.
  84. innodb_flush_log_at_trx_commit=
  85.  
  86. # The size of the buffer InnoDB uses for buffering log data. As soon as
  87. # it is full, InnoDB will have to flush it to disk. As it is flushed
  88. # once per second anyway, it does not make sense to have it very large
  89. # (even with long transactions).
  90. innodb_log_buffer_size=1M
  91.  
  92. # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
  93. # row data. The bigger you set this the less disk I/O is needed to
  94. # access data in tables. On a dedicated database server you may set this
  95. # parameter up to % of the machine physical memory size. Do not set it
  96. # too large, though, because competition of the physical memory may
  97. # cause paging in the operating system. Note that on 32bit systems you
  98. # might be limited to -.5G of user level memory per process, so do not
  99. # set it too high.
  100. innodb_buffer_pool_size=8M
  101.  
  102. # Size of each log file in a log group. You should set the combined size
  103. # of log files to about %-% of your buffer pool size to avoid
  104. # unneeded buffer pool flush activity on log file overwrite. However,
  105. # note that a larger logfile size will increase the time needed for the
  106. # recovery process.
  107. innodb_log_file_size=48M
  108.  
  109. # Number of threads allowed inside the InnoDB kernel. The optimal value
  110. # depends highly on the application, hardware as well as the OS
  111. # scheduler properties. A too high value may lead to thread thrashing.
  112. innodb_thread_concurrency=
  113.  
  114. # The increment size (in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
  115. innodb_autoextend_increment=
  116.  
  117. # The number of regions that the InnoDB buffer pool is divided into.
  118. # For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency,
  119. # by reducing contention as different threads read and write to cached pages.
  120. innodb_buffer_pool_instances=
  121.  
  122. # Determines the number of threads that can enter InnoDB concurrently.
  123. innodb_concurrency_tickets=
  124.  
  125. # Specifies how long in milliseconds (ms) a block inserted into the old sublist must stay there after its first access before
  126. # it can be moved to the new sublist.
  127. innodb_old_blocks_time=
  128.  
  129. # It specifies the maximum number of .ibd files that MySQL can keep open at one time. The minimum value is .
  130. innodb_open_files=
  131.  
  132. # When this variable is enabled, InnoDB updates statistics during metadata statements.
  133. innodb_stats_on_metadata=
  134.  
  135. # 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
  136. # in a separate .ibd file, rather than in the system tablespace.
  137. innodb_file_per_table=1
  138.  
  139. innodb_checksum_algorithm=
  140.  
  141. back_log=
  142.  
  143. flush_time=
  144.  
  145. join_buffer_size=256K
  146.  
  147. max_allowed_packet=4M
  148.  
  149. max_connect_errors=
  150.  
  151. open_files_limit=
  152.  
  153. query_cache_type=
  154.  
  155. sort_buffer_size=256K
  156.  
  157. table_definition_cache=
  158.  
  159. binlog_row_event_max_size=8K
  160.  
  161. sync_master_info=
  162.  
  163. sync_relay_log=
  164.  
  165. sync_relay_log_info=

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

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

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

  1. C:\Users\liqiang>tasklist |findstr mysql
  2. mysqld.exe Services , K
  3. mysqld.exe Console , K
  4. mysql.exe Console , K
  5.  
  6. C:\Users\liqiang>netstat -ano | findstr
  7. TCP 0.0.0.0: 0.0.0.0: LISTENING
  8. TCP [::]: [::]: LISTENING
  9. TCP [::]: [::]: ESTABLISHED
  10. TCP [::]: [::]: ESTABLISHED

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

  1. C:\Users\liqiang>mysql -uroot -p -P3307
  2. Enter password: ******
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is
  5. Server version: 5.7.-log MySQL Community Server (GPL)
  6.  
  7. Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql> show variables like 'log_error';
  16. +---------------+-----------------------+
  17. | Variable_name | Value |
  18. +---------------+-----------------------+
  19. | log_error | .\MicroWin10-.err |
  20. +---------------+-----------------------+
  21. row in set, warning (0.01 sec)
  22.  
  23. mysql> show variables like 'datadir';
  24. +---------------+-------------------+
  25. | Variable_name | Value |
  26. +---------------+-------------------+
  27. | datadir | G:\mysql572\Data\ |
  28. +---------------+-------------------+
  29. row in set, warning (0.00 sec)

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

需以管理员身份执行cmd

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

查看上面安装的服务:

  1. C:\Windows\system32>sc qc mysql572
  2. [SC] QueryServiceConfig 成功
  3.  
  4. SERVICE_NAME: mysql572
  5. TYPE : WIN32_OWN_PROCESS
  6. START_TYPE : AUTO_START
  7. ERROR_CONTROL : NORMAL
  8. BINARY_PATH_NAME : G:\mysql572\bin\mysqld --defaults-file=G:\mysql572\
  9. my.ini mysql572
  10. LOAD_ORDER_GROUP :
  11. TAG :
  12. DISPLAY_NAME : mysql572
  13. DEPENDENCIES :
  14. SERVICE_START_NAME : LocalSystem

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

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

  1. sc delete mysql572
  2.  
  3. 或者采用mysqld方式移除系统服务
  4.  
  5. mysqld --remove MySQL57

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

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

  1. 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. 小组成员及其git链接

    组名:天天向上 Github仓库:https://github.com/lvcaixia/test 组长:吕彩霞 201303014109(计科高职13-3) 第一题   https://github ...

  2. springboot+mybatis结合使用

    springboot+mybatis结合使用与普通的ssm配置差别不大,但是少了很多的配置,如spring.xml  web.xml,  给程序员减轻了很多负担 首先创建带有mybatis框架的项目 ...

  3. Beta 冲刺 一

    团队成员 051601135 岳冠宇 031602629 刘意晗 031602248 郑智文 031602330 苏芳锃 031602234 王淇 照片 项目进展 岳冠宇 昨天的困难 无 今天的进度 ...

  4. linux 取消控制台报警音

    可以通过setterm -blength 0 设置报警音报警时间,0表示没有报警音 也可以通过setterm -bfreq 10 设置报警音的频率(Hz) 如果通过命令行直接设置,当下会生效,但是重启 ...

  5. orcle 远程连接其他数据库 进行查询数据

    CREATE PUBLIC DATABASE LINK testlinkCONNECT TO hxka IDENTIFIED BY bjdscoalUSING '(DESCRIPTION =(ADDR ...

  6. Entity Framework(EF) Code First将实体中的string属性映射成text类型的几种方式

    1.通过ColumnType属性设置 [Column(TypeName="text")] public string Text { get; set; } 在进行以上属性设置时,请 ...

  7. REQUIRES_NEW 如果不在一个事务那么自己创建一个事务 如果在一个事务中 自己在这个大事务里面在创建一个子事务 相当于嵌套事务 双层循环那种

    REQUIRES_NEW   如果不在一个事务那么自己创建一个事务 如果在一个事务中 自己在这个大事务里面在创建一个子事务  相当于嵌套事务 双层循环那种 不管是否存在事务,业务方法总会自己开启一个事 ...

  8. shell之三大文本处理工具grep、sed及awk

    grep.sed和awk都是文本处理工具,虽然都是文本处理工具单却都有各自的优缺点,一种文本处理命令是不能被另一个完全替换的,否则也不会出现三个文本处理命令了.只不过,相比较而言,sed和awk功能更 ...

  9. BZOJ2728 HNOI2012与非(并查集+数位dp)

    容易发现x nand x=not x.并且使用这个性质有x and y=not(x nand y)=(x nand y)nand(x nand y).也就是说nand运算可以作为not和and运算使用 ...

  10. C++11 初始化

    C++11 初始化 统一初始化语法        C++11新添加初始化列表 std::initializer_list<>类型,可以通过{}语法来构造初始化列表 .初始化列表是常数:一旦 ...