您现在的位置是:首页 > 编程 > 

JDK Tomcat MySQL一键安装

2025-07-17 21:01:09
文章目录 材料准备免安装版JDK免安装版Tomcat免安装版MySQL微软Visual C运行库组件打包工具Inno Setup 统一目录创建所需文件(先创建好清楚整体流程)整体结构文件内容测试 打包步骤 历时两天, 材料

文章目录

    • 材料准备
      • 免安装版JDK
      • 免安装版Tomcat
      • 免安装版MySQL
      • 微软Visual C运行库组件
      • 打包工具Inno Setup
    • 统一目录
    • 创建所需文件(先创建好清楚整体流程)
    • 整体结构
    • 文件内容
      • 测试
    • 打包步骤

历时两天,

材料准备

免安装版JDK

下载需要的JDK安装版,安装之后直接复制整个目录即可-----》JDK8下载链接

免安装版Tomcat

下载解压版解压即可-----》Tomcat8.5下载链接

免安装版MySQL

下载解压版即可-----》MySQL免安装版链接

微软Visual C运行库组件

下载相应的版本即可-----》201版链接

打包工具Inno Setup

下载安装即可-----》链接

统一目录

准备好上述材料之后,小熙建议直接在桌面新建文件夹便于操作(看个人喜好)

  1. 桌面新建文件夹Version4.2
  2. 将Tomcatcat和MySQL移动到该目录下
  3. 将JDK移动到Tomcat的bin目录下
  4. 注意:JDK、Tomcat 、MySQL的文件夹名字是可以随意改的,建议修改-----》去掉版本号等东西,便于路径的书写和防止出错。
创建所需文件(先创建好清楚整体流程)
  1. JDK启动脚本AutoJDK.bat-----》在JDK的bin目录下新建文本文档,修改后缀为.bat,取名随意。
  2. Tomcat启动脚本AutoTomcat.bat-----》在tomcat的bin目录下新建文本文档,修改后缀为.bat,取名随意。
  3. MySQL启动脚本AutoMySQL.bat-----》在MySQL的bin目录下新建文本文档,修改后缀为.bat,取名随意。
  4. MySQL修改安装路径配置脚本updatemyini.bat-----》在MySQL目录先直接新建文本文档,修改后缀为.bat,取名随意。
  5. MySQL配置文件my.ini-----》此文件为MySQL自带的配置文件。如果你的MySQL下没有此文件,也没有mydefault.ini文件,请直接新建文本文档,修改后缀为.ini,取名必须为my。如果有my.ini则无需创建。如果有mydefault.ini,复制一份改名为my.ini,其中mydefault.ini不需要删除。
  6. 打包脚本文件adk.iss-----》在根目录下(即MySQL,Tomcat同级目录)新建文本文档,修改后缀为.iss,取名随意。
  7. 数据库文件夹-----》在MySQL下创建data文件夹。
  8. SQL语句文件夹-----》在MySQL下创建sql文件夹。
  9. 数据库文件databasename.sql-----》导出你的数据库,以.sql结尾,放入MySQL下的sql文件夹中。
  10. 数据库文件建库文件-----》如果你导出的sql文件中没有建库语句(如果有小熙建议删除,然后使用本方法),请新建文本文档,修改后缀为.sql,取名随意,放入MySQL下的sql文件夹中。(看了其他的博客只用了一个sql文件,但是自动执行的时候MySQL会报错,没有选择数据库,采用此双sql文件的方法可完美解决)
  11. war包项目:将项目打包成war包,放在tomcat下的webapps下即可。
整体结构

请参考整体结构检查自己的结构是否正确,如果不同请调整(其实目录可以随意放,但是后续批处理脚本需要操作这些文件,涉及到路径问题,为避免麻烦和错误,请与小熙一致)

  1. 项目结构
  2. tomcat结构
  3. JDK所在目录
  4. JDK启动脚本
  5. mysql结构
  6. mysql启动脚本

    以上就是所有的结构信息,修改完后就要进入最难啃的批处理命令环节了,不怕,小熙一步一步教会你。
文件内容
  1. JDK启动脚本(其作用是自动配置环境变量)内容如下(复制到AutoJDK.bat即可):
@echo off

echo  ------begin----

rem 返回上一级目录,即jdk根目录
cd ..

echo %~dp0
echo %cd%
set jdkpath=%cd%
echo %jdkpath%

rem 设置JAVA_HOME环境变量
setx JAVA_HOME %jdkpath% -m

rem 设置CLASSPATH环境变量
setx CLASSPATH .;%%JAVA_HOME%%\lib\tools.jar;%%JAVA_HOME%%\lib\dt.jar -m

echo %Path%
echo %Path%|find /i %java_home% && set Isull=true || set Isull=false
echo %Isull%

if not %Isull%==true (
reg add HKEY_LOCAL_MACHIE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment /v Path /t REG_SZ /d %Path%;%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin /f

rem 追加path变量
setx Path %%JAVA_HOME%%\bin;%Path%

)
exit

  1. tomcat启动脚本(其作用是自动将tomcat配置为服务自动启动,避免黑窗口启动方式关闭黑窗口后tomcat停止运行的问题)内容如下(复制到AutoTomcat.bat即可):
echo  -------tomcat begin--------

rem 执行service.bat脚本
call %~dp0%service.bat install tomcat

echo  -------tomcat install end------------------

sc config tomcat start= auto
net start tomcat

exit

  1. MySQL启动脚本(其作用是自动将配置mysql服务,自动创建数据库,创建导入数据表)内容如下(复制到AutoMySQL.bat即可):

cd ..

call updatemyini

cd bin

cd /d %~dp0

%cd%\ --initialize-insecure --user=mysql --cole



echo -----mysql init succee-----

cd ..

set MYSQL_HOME=%cd%

cd bin

mysqld install mysql --defaults-file=%MYSQL_HOME%\my.ini

echo -----mysql service install succee-----


net start mysql

sc config mysql start= auto



net stop mysql


net start mysql


%cd%\mysqladmin -u root password 12456
echo --password success

cd ..

%cd%\bin\ -uroot -p12456 < %cd%\sql\qudao1.sql
%cd%\bin\ -uroot -p12456 qudao < %cd%\sql\qudao2.sql

echo -----create database succee-----


echo -----mysql service command succee-----


  1. MySQL修改安装路径配置脚本(其作用是自动修改数据库安装路径,由于无法确定客户安装到那个目录,所以动态修改数据库的路径datadir和basedir,有的教程是在打包期间进行修改,但是会加大测试难度,小熙搞这个搞了两天,测试修改了三十多次,不可能每次都全部打包进行测试,所以建议使用小熙的方法)内容如下(复制到updatemyini.bat即可):
@echo off&setlocal EABLEDELAYEDEXPASIO

set basedir=%~DP0
set datadir=%~DP0data/
(for /f tokens=1* delims=: %%a in (	FIDSTR /n .* my.ini	) do (
    for /f delims==  %%i in (%%b) do (
        if defined %%i (echo;%%i=!%%i:\=/!)else echo;%%b
)))>$
move $ my.ini
  1. my.ini文件(其作用是自动配置mysql,直接使用小熙的文件即可,其中内容无需修改,除非你还想搞点别的,哈哈)内容如下(复制到my.ini即可):
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
# Installation Instructi
# ----------------------------------------------------------------------
# On Linux you can copy this file to /etc/myf to set global opti,
# mysql-data-dir/myf to set server-specific opti
# (@localstatedir@ for this installation) or to
# ~/.myf to set user-specific opti.
# On Windows you should keep this file in the installation directory 
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# --defaults-file. 
#
# To run run the server from the command line, execute this in a 
# command line shell, e.g.
# mysqld --defaults-file=C:\Users\Administrator\Desktop\mysql\my.ini
#
# To install the server as a Windows service manually, execute this in a 
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file=C:\Users\Administrator\Desktop\mysql\my.ini
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
# Guildlines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long opti that the program supports.
# If you want to know the opti a program supports, start the program
# with the --help option.
#
# More detailed information about the individual opti can also be
# found in the manual.
#
# CLIET SECTIO
# ----------------------------------------------------------------------
#
# The following opti will be read by MySQL client applicati.
# ote that only client applicati shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=06
[mysql]
default-character-set=utf8
# SERVER SECTIO
# ----------------------------------------------------------------------
#
# The following opti will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
[mysqld]
federated 
skip-external-locking 
skip-name-resolve 
skip-grant-tables 
# The TCP/IP Port the MySQL Server will listen on
port=06
#Path to installation directory. All paths are usually resolved relative to this.
basedir=C:\Users\Administrator\Desktop\mysql
#Path to the database root
datadir=C:\Users\Administrator\Desktop\mysql\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=IODB
# Set the SQL mode to strict
sql-mode=STRICT_TRAS_TABLES,O_AUTO_CREATE_USER,O_EGIE_SUBSTITUTIO
# The maximum amount of concurrent sessi the MySQL server will
# allow. One of these connecti will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connecti=100
# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# Qcache_lowmem_prunes status variable to check if the current value
# is high enough for your load.
# ote: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=2M
# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable open-files-limit in
# section [mysqld_safe]
table_open_cache=256
# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=5M
# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client	s threads are put in the cache if there aren	t
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creati needed if you have a lot of new
# connecti. (ormally this doesn	t give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=8
#*** MyISAM Specific opti
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA IFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G
# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=69M
# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 0% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you	re not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=50M
# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K
# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA IFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K
#*** IODB Specific opti ***
# 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
# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW IODB STATUS will display the current amount used.
#innodb_additional_mem_pool_size=14M
# 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
# transacti, 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 transacti).
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.  ote that on 2bit systems you
# might be limited to 2-.5G of user level memory per process, so do not
# set it too high.
innodb_buffer_pool_size=96M
# 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=20M
# umber 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=18

  1. 打包脚本文件(其作用是将整个项目打包成exe可执行文件,自动调用三个启动脚本)内容如下(复制到adk.iss即可):
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMETATIO FOR DETAILS O CREATIG IO SETUP SCRIPT FILES!

#define MyAppame baidu
#define MyAppVersion 1.0
#define MyAppPublisher baidu
#define MyAppURL http://www.baidu/
#define MyAppExeame 

[Setup]
; OTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applicati.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{FDFD0778-244E-4D04-A78A-F54FD5D675E}
Appame={#MyAppame}
AppVersion={#MyAppVersion}
AppVerame={#MyAppame} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirame={pf}\{#MyAppame}
DisableProgramGroupPage=yes
OutputBaseFilename=BaiDu
Compression=lzma
SolidCompression=yes

[Languages]
ame: english; MessagesFile: compiler:Default.isl

[Tasks]
ame: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIc}; Flags: unchecked

[Files]
;拷贝tomcat

Source:C:\Users\hhh\Desktop\Version.2\tomcat\*;DestDir:{app}\tomcat;Flags:igoreversion recursesubdirs createallsubdirs


;拷贝mysql

Source:C:\Users\hhh\Desktop\Version.2\mysql\*;DestDir:{app}\mysql;Flags:igoreversion recursesubdirs createallsubdirs

[Ic]
ame: {commonprograms}\{#MyAppame}; Filename: {app}\{#MyAppExeame}
ame: {commondesktop}\{#MyAppame}; Filename: http://localhost:80/adkfp; 

[Run]
;执行三个bat文件

Filename: {app}\tomcat\bin\java\jdk-8u201\bin\AutoJDK.bat;

Filename: {app}\tomcat\bin\AutoTomcat.bat;

Filename: {app}\mysql\bin\AutoMySQL.bat;

注释:
OutputBaseFilename=baidu-----》你的exe可执行文件的名字
7. 数据库建库sql文件(其作用是创建数据库,就一行sql语句)内容如下(复制到adk.iss即可):

CREATE DATABASE yourdatabasename;

测试

小熙建议每个模块单独测试之后再进行打包操作,不然各种错误足够折腾了,一步一步稳步前行才是真的。测试环境最好是纯净版本的Windows系统,没有安装过以上三大软件的,如果有请清理掉,建议在虚拟机进行(小熙刚好有一台快到期的云服务器,哈哈,测试一遍重装一遍系统,反正云服务器一键搞定)

  1. 测试JDK

    1. 将tomcat目录复制到的环境中(桌面即可)
    2. 进入AutoJDK.bat的目录双击启动
    3. 黑窗口一闪而过(如果娘=你想看看发生了什么,请在AutoJDK.bat末尾添加pause暂停命令)
    4. WindowsR-----》 cmd -----》java -version 这个大家都会吧。。。。查看一下是否安装好
    5. JDK是基本不会出问题的,tomcat和mysql涉及服务的问题会多一些。
    6. 如果测试成功了,就进行下一步Tomcat了。
  2. 测试Tomcat

    1. 进入AutoTomcat.bat的目录双击启动
    2. 黑窗口依旧一闪而过(如果加了pause暂停,打包前一定要去掉,尽量减少客户操作嘛,把客户当成。。。。你懂)
    3. 打开浏览器输入localhost:8080即可,添加了项目也可以测试项目呀,随你,端口冲突什么的不用教怎么改了吧。。。。
打包步骤

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/biancheng/1104024.html

相关标签:无
上传时间: 2025-07-16 01:25:15
留言与评论(共有 10 条评论)
本站网友 洞玄子
3分钟前 发表
\Program Files\MySQL\MySQL Server X.Y). To # make sure the server reads the config file use the startup option # --defaults-file. # # To run run the server from the command line
本站网友 我的一张大字报
24分钟前 发表
used to cache index blocks for MyISAM tables. # Do not set it larger than 0% of your available memory
本站网友 台鉴
24分钟前 发表
\Users\Administrator\Desktop\mysql #Path to the database root datadir=C
本站网友 activex控件
6分钟前 发表
start the program # with the --help option. # # More detailed information about the individual opti can also be # found in the manual. # # CLIET SECTIO # ---------------------------------------------------------------------- # # The following opti will be read by MySQL client applicati. # ote that only client applicati shipped by MySQL are guaranteed # to read this section. If you want your own MySQL client program to # honor these values
本站网友 altimeter
1分钟前 发表
ALTER TABLE or LOAD DATA IFILE. # If the file-size would be bigger than this
本站网友 金陵在线
23分钟前 发表
MySQL启动脚本AutoMySQL.bat-----》在MySQL的bin目录下新建文本文档,修改后缀为.bat,取名随意
本站网友 最先进的玉米收割机
17分钟前 发表
igoreversion recursesubdirs createallsubdirs ;拷贝mysql Source
本站网友 英强博客
20分钟前 发表
MySQL配置文件my.ini-----》此文件为MySQL自带的配置文件
本站网友 北京个人房屋出租
15分钟前 发表
\Users\Administrator\Desktop\mysql #Path to the database root datadir=C