荐 java实训日记_环境准备
前言
从明天开始java实习,其实更像是培训,最终是要完成一个分销商城项目,在此开一个合集记录这次开发中遇到的问题。
需要准备的环境
1.HbuilderX(前端)
2.Eclipse(后端)
3.SQLyog或者navicat(数据库管理工具)
4.Mysql5.7(数据库)
5.JAVA(JDK1.8)
6.Tomcat(8.5)
因为Eclipse、JDK之前就有了,所以不说了。MySQL和Tomcat之前有,但版本不同,为了防止出现问题还是准备相同版本的把。
HbuilderX
下载地址:https://www.dcloud.io/hbuilderx.html
解压可用,非常方便。
Navicat
官网下载地址:http://www.navicat.com.cn/products
14天试用。
MySQL5.7
之前已经安装过MySQL8了,但是要求用低版本的就用吧,因为我比较习惯用配置的方式,但是网上5.多版本都是运行安装程序进行安装的,所以我就尝试着翻译一下MySQL的配置文件尝试自己配置,也加深对 MySQL的了解
MySQL官方下载地址:https://downloads.mysql.com/archives/community/
也可以百度一些镜像进行下载,镜像网站记得下载对应操作系统的版本。
因为我的系统是8g内存,大概可以有512M的内存可以用于MySQL,所以基于my-large.ini进行配置,文件和用于mysql的内存如下表
文件名 | 用于MySQL的内存大小 |
---|---|
my-small.ini | <=64M |
my-medium.ini | 32M-64M |
my-large.ini | 512M |
my-huge.ini | 1G-2G |
my-innodb-heavy-4G.ini | 4GB,innoDDB only,ACID,few onnections,heacy queries |
那么就开始翻译
# Example MySQL config file for large systems.
# MySQL大系统配置文件实例
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
# 这是一个大约有512M内存主要用于MySQL的大系统的配置文件
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
# MySQL项目会根据部署平台在一个地址集中寻找配置文件,你可以拷贝这个配置文件,放到地址之中,
# 更多关于这些地址的信息可以查阅 http://dev.mysql.com/doc/mysql/en/option-files.html
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# 在这个文件中,你可以使用项目支持的所有长配置,如果你想知道一个项目支持什么配置,带参数“--help”运行该
# 项目
# The following options will be passed to all MySQL clients
# 下面的配置将会传递给所有MySQL的客户
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
#密码、端口、套接字(暂时不知道套接字有什么用)
# Here follows entries for some specific programs
# 下面是一些特殊程序的条目
# The MySQL server
# MySQL的服务端
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
# 尝试为thread_concurrency配置CPU的线程数的两倍
thread_concurrency = 8
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 不要在一个TCP/IP端口监听,这可以是一种安全性增强,如果所有需要连接mysqld的进程在同一个端口上运行,
# 所有与mysqld的交互必须通过Unix sockets或被命名的管道,记住在Windows平台上没有开启启用管道命名(
# 通过“enable-named-pipe选项”)就使用这个配置会导致提交mysqld无效!
#skip-networking
# 跳过网络配置
# Replication Master Server (default)
# 复制主服务器(默认)
# binary logging is required for replication
# 复制需要二进制日志登记
log-bin=mysql-bin
# binary logging format - mixed recommended
# 二进制日志登记格式-推荐mixed
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
# 需要介于1到2^32-1的一个唯一id,如果master-host没有设置那么默认是1,缺省则不作为主服务器。
server-id = 1
# Replication Slave (comment out master section to use this)
# 复制从属服务器(将主服务器段注释掉来使用这个)
# To configure this host as a replication slave, you can choose between
# two methods :
# 为了将这个主机配置为复制从属服务器,你可以选择以下两种模式。
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
# 1)使用CHANGE MASTER TO 命令(在我们的手册中有详细的描述),语法是
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
# 将<host><user><password>替换为引用的字符串,<port>替换为主服务器端口数字(默认为3306)
# Example:
# 例子
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
# 或者
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
# 配置下方的变量。但是,为了防止你第一次使用这种方式启动复制(即使是失败了,比如你拼错了主服务器的
# 密码导致从属连接失败),从属会创建一个master.info文件,并且接下来在本文件中对下方变量的所有修改
# 将会被忽略并且被文件中的变量值覆盖,除非你停止了从属服务器,删除master.info文件并重启从属服务器。
# 因此,你也许会是下方的语句不被执行(注释掉)并且使用CHANGE MASTER TO(见上方)
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
# 与上一个server-id的注释相同
#server-id = 2
# The replication master for this slave - required
# 这个从属服务器的主服务器 -必须
#master-host = <hostname>
# The username the slave will use for authentication when connecting
# to the master - required
# 从属服务器连接到主服务器进行身份验证时会用到 -必须
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
# 从属服务器连接到主服务器进行身份验证时会用到 -必须
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
# 主服务器监听的端口 可选-默认3306
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
# 二进制日志登记 -从属服务器不是必须的,但建议有
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
# 如果你使用innoDb表,将下方的语句取消注释
#innodb_data_home_dir = C:\\mysql\\data\\
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\\mysql\\data\\
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
# 你可以设置buffer_pool_size高达内存的50-80%,但是要注意不要将内存使用量设置得太高
#innodb_buffer_pool_size = 256M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
# 设置 .._log_file_size 为buffer pool size的25%
#innodb_log_file_size = 64M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
# 如果你不熟悉SQL,将下面的语句取消注释
#safe-updates
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
关于Repilcation那段可以看MySQL Replication(Master与Slave基本原理及配置),时间关系我没来得及细看,不多说。
将源文件复制一份,重命名为my.ini,最终文件如下,想要使用需要修改 innodb_data_home_dir,innodb_log_group_home_dir的值,目前不知道safe-update会发生什么,但是不太懂mysql所以就开着了,在这里我改了password但是后面登录的时候输入密码错了,空密码反而进去了,原因不明。
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
# Replication Master Server (default)
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\\mysql\\data\\
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\\mysql\\data\\
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
safe-updates
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
写完配置文件以后,就要开始安装了,因为之前安装过MySQL8,所以先卸载了,在命令行中使用mysqld -remove 卸载,卸载失败要用管理员运行命令行再次尝试。使用mysqld -install安装,看到下面这个样子就是安装成功了,但是安装成功不一定可以用,具体看下面出现的错误。
出现的错误: errcode2这个在对应的地方建一个文件夹就好了。
10061这个是因为mysql服务没有启动,启动以下就好了,之前安装过mysql8,确认服务的可执行文件的路径要对,而且要修改环境变量(如果设置了的话),修改了环境变量要重新打开命令行。
1045这个是因为密码错误,直接回车就行了
最终出现下面的画面就是成功了,盘符那里变成了mysql>,然后可以根据参考文献1中的方法修改一下登录密码
Tomcat8.5
官网下载地址:https://tomcat.apache.org/download-80.cgi
注意要下载Binary Distributions下的压缩包,SourceCode里面的压缩包是不能运行的。
修改环境变量中的CATALINA_HOME,解压后运行bin目录下的startup.bat,在浏览器输入localhost:8080,看到下图即表示成功,要注意tomcat版本是不是正确。
参考链接
1.MySQL5.5绿色版服务配置
2.Install/Remove of the Service Denied解决办法
3.MySQL Replication(Master与Slave基本原理及配置)
本文地址:https://blog.csdn.net/xklx_z/article/details/107305619
上一篇: 美图看看一键批量传图到QQ空间教程
下一篇: C语言实现数字炸弹小游戏