首先先确定windows系统是32位还是64位
下载对应的Mysql和Tomcat版本
Mysql:MySQL 5.6.45
下载地址:百度网盘下载 提取码:xglj
Tomcat:Tomcat 8.5
下载地址:官方下载
1、Mysql应用部署
下载完Mysql压缩包后,解压到指定硬盘,配置my.ini文件,默认基础配置即可
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
log-output=FILE
general-log=1
general_log_file="mysql.log"
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
port=3306
default-character-set=utf8
[mysql]
default-character-set=utf8
2、Mysql初始化
(1)启动mysql
进入mysql的bin目录下,在空白处按住shift+鼠标右键,打开PowerShell窗口,运行mysqld启动mysql
(2)配置mysql的root用户密码
刚开始的Mysql的root用户是无密码,直接在bin目录下输入 mysql -u root -p 点击回车即可进入mysql
进入后Mysql后可使用 show databases; 查看所有数据库数据库
这里我们使用mysql 数据库,输入 use mysql; 命令即可,回车。
再输入以下命令,修改root密码为123456(可自定义)
update user set password=password("123456") where user="root";
点击回车即可执行。
再刷新权限(不刷新则在当前运行的mysql无效)
flush privileges;
点击回车即可执行。
修改root密码成功,退出mysql;
quit;
(3)注册mysql服务
编写initMysqlService.bat文件,如下:
======autoMysql.bat==begin======
echo
call "%~dp0%mysqld" install mysql5.6
echo
sc config mysql5.6 start= auto
sc start mysql5.6
rem 下面两句是设置到服务里自动启动的
wmic service where name="mysql5.6" changestartmode "automatic"
wmic service where name="mysql5.6" startservice
exit
======autoMysql.bat==end======
放置在MySQL的bin目录,右键以管理员身份运行即可。
3、Tomcat安装
小编的Java和tomcat是免安装版的,放置在Tomcat的bin目录下,电脑无需配置java环境变量,即可启动tomcat,只需要修改catalina.bat(tomcat启动)和service.bat(注册服务)文件即可,在bat文件里面指定java环境路径,如下:
修改catalina.bat文件
在setlocal下添加以下代码块
set JAVA_HOME=%cd%\Java
set JRE_HOME=%cd%\Java\jre
修改service.bat文件
在setlocal下添加以下代码块
set JAVA_HOME=%cd%\Java
set JRE_HOME=%cd%\Java\jre
4、Tomcat初始化
(1)Tomcat修改端口号和路径等相关配置都在server.xml文件里
(2)Tomcat注册服务
编写initTomcat.bat脚本文件
echo
call "%~dp0%service.bat" install tomcat8.5
echo
sc config tomcat8.5 start= auto
sc start tomcat8.5
rem 下面两句是设置到服务里自动启动的
wmic service where name="tomcat8.5" changestartmode "automatic"
wmic service where name="tomcat8.5" startservice
exit
放置在Tomcat的bin目录下,右键以管理员方式运行即可完成
需要注意的是如果Tomcat注册服务无法正常启动的话,可以尝试把原来需要拷贝Java的bin目录下的msvcr100.dll到tomcat的bin目录,然后在重新注册一遍即可运行。