当前位置:   article > 正文

jdk、maven、mysql的安装配置_mysql maven

mysql maven

目录

一、jdk环境变量配置

二、maven环境变量配置

三、mysql数据库配置

一、jdk环境变量配置

jdk官网下载相应安装包:网址:Java Downloads | Oraclehttps://www.oracle.com/java/technologies/downloads/#java8-windows

1、在系统变量里新建如图所示变量:

                变量名:JAVA_HOME
                变量值:D:\Study\java\jdk1.8.0_321

2、再在系统变量里新建如图所示变量:
                变量名:CLASSPATH
                变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

3、在path变量下分别新建如下两个变量值

%JAVA_HOME%\bin

%JAVA_HOME%\jre\bin

4、验证是否配置成功:打开cmd,

输入 java -version
        javac -version
        javaw
如图下图就证明成功啦!

(只在idea里用java的话没必要配置环境变量)

二、maven环境变量配置

1、在系统变量里新建如图所示变量:(根据自己的maven路径来)
                变量名:MAVEN_HOME
                变量值:D:\Study\Maven\apache-maven-3.8.4

2、打开path环境变量,然后新建如下路径

 验证:打开cmd,输入mvn -v   显示版本信息就行

类似下图

3、我配好的settings.xml文件如下(我用的jdk1.8,所以这个文件里配置的默认jdk为1.8的,如果不一致,自己就可以改,比如你用jdk17,把1.8改成17即可)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing,
  12. software distributed under the License is distributed on an
  13. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. KIND, either express or implied. See the License for the
  15. specific language governing permissions and limitations
  16. under the License.
  17. -->
  18. <!--
  19. | This is the configuration file for Maven. It can be specified at two levels:
  20. |
  21. | 1. User Level. This settings.xml file provides configuration for a single user,
  22. | and is normally provided in ${user.home}/.m2/settings.xml.
  23. |
  24. | NOTE: This location can be overridden with the CLI option:
  25. |
  26. | -s /path/to/user/settings.xml
  27. |
  28. | 2. Global Level. This settings.xml file provides configuration for all Maven
  29. | users on a machine (assuming they're all using the same Maven
  30. | installation). It's normally provided in
  31. | ${maven.conf}/settings.xml.
  32. |
  33. | NOTE: This location can be overridden with the CLI option:
  34. |
  35. | -gs /path/to/global/settings.xml
  36. |
  37. | The sections in this sample file are intended to give you a running start at
  38. | getting the most out of your Maven installation. Where appropriate, the default
  39. | values (values used when the setting is not specified) are provided.
  40. |
  41. |-->
  42. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  43. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  44. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  45. <!-- localRepository
  46. | The path to the local repository maven will use to store artifacts.
  47. |
  48. | Default: ${user.home}/.m2/repository
  49. <localRepository>/path/to/local/repo</localRepository>
  50. -->
  51. <localRepository>C:/Program Files/Maven/repository</localRepository>
  52. <!-- interactiveMode
  53. | This will determine whether maven prompts you when it needs input. If set to false,
  54. | maven will use a sensible default value, perhaps based on some other setting, for
  55. | the parameter in question.
  56. |
  57. | Default: true
  58. <interactiveMode>true</interactiveMode>
  59. -->
  60. <!-- offline
  61. | Determines whether maven should attempt to connect to the network when executing a build.
  62. | This will have an effect on artifact downloads, artifact deployment, and others.
  63. |
  64. | Default: false
  65. <offline>false</offline>
  66. -->
  67. <!-- pluginGroups
  68. | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
  69. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
  70. | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
  71. |-->
  72. <pluginGroups>
  73. <!-- pluginGroup
  74. | Specifies a further group identifier to use for plugin lookup.
  75. <pluginGroup>com.your.plugins</pluginGroup>
  76. -->
  77. </pluginGroups>
  78. <!-- proxies
  79. | This is a list of proxies which can be used on this machine to connect to the network.
  80. | Unless otherwise specified (by system property or command-line switch), the first proxy
  81. | specification in this list marked as active will be used.
  82. |-->
  83. <proxies>
  84. <!-- proxy
  85. | Specification for one proxy, to be used in connecting to the network.
  86. |
  87. <proxy>
  88. <id>optional</id>
  89. <active>true</active>
  90. <protocol>http</protocol>
  91. <username>proxyuser</username>
  92. <password>proxypass</password>
  93. <host>proxy.host.net</host>
  94. <port>80</port>
  95. <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
  96. </proxy>
  97. -->
  98. </proxies>
  99. <!-- servers
  100. | This is a list of authentication profiles, keyed by the server-id used within the system.
  101. | Authentication profiles can be used whenever maven must make a connection to a remote server.
  102. |-->
  103. <servers>
  104. <!-- server
  105. | Specifies the authentication information to use when connecting to a particular server, identified by
  106. | a unique name within the system (referred to by the 'id' attribute below).
  107. |
  108. | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  109. | used together.
  110. |
  111. <server>
  112. <id>deploymentRepo</id>
  113. <username>repouser</username>
  114. <password>repopwd</password>
  115. </server>
  116. -->
  117. <!-- Another sample, using keys to authenticate.
  118. <server>
  119. <id>siteServer</id>
  120. <privateKey>/path/to/private/key</privateKey>
  121. <passphrase>optional; leave empty if not used.</passphrase>
  122. </server>
  123. -->
  124. </servers>
  125. <!-- mirrors
  126. | This is a list of mirrors to be used in downloading artifacts from remote repositories.
  127. |
  128. | It works like this: a POM may declare a repository to use in resolving certain artifacts.
  129. | However, this repository may have problems with heavy traffic at times, so people have mirrored
  130. | it to several places.
  131. |
  132. | That repository definition will have a unique id, so we can create a mirror reference for that
  133. | repository, to be used as an alternate download site. The mirror site will be the preferred
  134. | server for that repository.
  135. |-->
  136. <!-- mirror
  137. <mirrors>
  138. | Specifies a repository mirror site to use instead of a given repository. The repository that
  139. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
  140. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
  141. |
  142. <mirror>
  143. <id>mirrorId</id>
  144. <mirrorOf>repositoryId</mirrorOf>
  145. <name>Human Readable Name for this Mirror.</name>
  146. <url>http://my.repository.com/repo/path</url>
  147. </mirror>
  148. </mirrors>
  149. -->
  150. <mirrors>
  151. <mirror>
  152. <id>alimaven</id>
  153. <name>aliyun maven</name>
  154. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  155. <mirrorOf>central</mirrorOf>
  156. </mirror>
  157. <mirror>
  158. <id>central</id>
  159. <name>Maven Repository Switchboard</name>
  160. <url>http://repo1.maven.org/maven2/</url>
  161. <mirrorOf>central</mirrorOf>
  162. </mirror>
  163. <mirror>
  164. <id>repo2</id>
  165. <mirrorOf>central</mirrorOf>
  166. <name>Human Readable Name for this Mirror.</name>
  167. <url>http://repo2.maven.org/maven2/</url>
  168. </mirror>
  169. <mirror>
  170. <id>ibiblio</id>
  171. <mirrorOf>central</mirrorOf>
  172. <name>Human Readable Name for this Mirror.</name>
  173. <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
  174. </mirror>
  175. <mirror>
  176. <id>jboss-public-repository-group</id>
  177. <mirrorOf>central</mirrorOf>
  178. <name>JBoss Public Repository Group</name>
  179. <url>http://repository.jboss.org/nexus/content/groups/public</url>
  180. </mirror>
  181. <!-- 中央仓库在中国的镜像 -->
  182. <mirror>
  183. <id>maven.net.cn</id>
  184. <name>oneof the central mirrors in china</name>
  185. <url>http://maven.net.cn/content/groups/public/</url>
  186. <mirrorOf>central</mirrorOf>
  187. </mirror>
  188. </mirrors>
  189. <!-- profiles
  190. | This is a list of profiles which can be activated in a variety of ways, and which can modify
  191. | the build process. Profiles provided in the settings.xml are intended to provide local machine-
  192. | specific paths and repository locations which allow the build to work in the local environment.
  193. |
  194. | For example, if you have an integration testing plugin - like cactus - that needs to know where
  195. | your Tomcat instance is installed, you can provide a variable here such that the variable is
  196. | dereferenced during the build process to configure the cactus plugin.
  197. |
  198. | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
  199. | section of this document (settings.xml) - will be discussed later. Another way essentially
  200. | relies on the detection of a system property, either matching a particular value for the property,
  201. | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
  202. | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
  203. | Finally, the list of active profiles can be specified directly from the command line.
  204. |
  205. | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
  206. | repositories, plugin repositories, and free-form properties to be used as configuration
  207. | variables for plugins in the POM.
  208. |
  209. |-->
  210. <!-- profile
  211. <profiles>
  212. | Specifies a set of introductions to the build process, to be activated using one or more of the
  213. | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
  214. | or the command line, profiles have to have an ID that is unique.
  215. |
  216. | An encouraged best practice for profile identification is to use a consistent naming convention
  217. | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
  218. | This will make it more intuitive to understand what the set of introduced profiles is attempting
  219. | to accomplish, particularly when you only have a list of profile id's for debug.
  220. |
  221. | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
  222. <profile>
  223. <id>jdk-1.4</id>
  224. <activation>
  225. <jdk>1.4</jdk>
  226. </activation>
  227. <repositories>
  228. <repository>
  229. <id>jdk14</id>
  230. <name>Repository for JDK 1.4 builds</name>
  231. <url>http://www.myhost.com/maven/jdk14</url>
  232. <layout>default</layout>
  233. <snapshotPolicy>always</snapshotPolicy>
  234. </repository>
  235. </repositories>
  236. </profile>
  237. -->
  238. <!--
  239. | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
  240. | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
  241. | might hypothetically look like:
  242. |
  243. | ...
  244. | <plugin>
  245. | <groupId>org.myco.myplugins</groupId>
  246. | <artifactId>myplugin</artifactId>
  247. |
  248. | <configuration>
  249. | <tomcatLocation>${tomcatPath}</tomcatLocation>
  250. | </configuration>
  251. | </plugin>
  252. | ...
  253. |
  254. | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
  255. | anything, you could just leave off the <value/> inside the activation-property.
  256. |
  257. <profile>
  258. <id>env-dev</id>
  259. <activation>
  260. <property>
  261. <name>target-env</name>
  262. <value>dev</value>
  263. </property>
  264. </activation>
  265. <properties>
  266. <tomcatPath>/path/to/tomcat/instance</tomcatPath>
  267. </properties>
  268. </profile>
  269. -->
  270. <profiles>
  271. <profile>
  272. <id>jdk-1.8</id>
  273. <activation>
  274. <activeByDefault>true</activeByDefault>
  275. <jdk>1.8</jdk>
  276. </activation>
  277. <properties>
  278. <maven.compiler.source>1.8</maven.compiler.source>
  279. <maven.compiler.target>1.8</maven.compiler.target>
  280. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  281. </properties>
  282. </profile>
  283. </profiles>
  284. <!-- activeProfiles
  285. | List of profiles that are active for all builds.
  286. |
  287. <activeProfiles>
  288. <activeProfile>alwaysActiveProfile</activeProfile>
  289. <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  290. </activeProfiles>
  291. -->
  292. </settings>

三、mysql数据库配置

1、数据库官方下载MySQL官方下载https://dev.mysql.com/downloads/mysql/

我就喜欢下载最新版,无所畏惧(偷笑),下载后解压到任意目录下(路径里不要有中文)。

接下来点击"No thanks,just start mydownload",等待下载好。

2、在系统变量path下,配置mysql路径。

 

3、 编写my.ini文件,修改basedir的路径,放到mysql-8.0.28-winx64目录下,

注意:最好清除文件里的汉字即把注释删掉,否则可能会报乱码的错。如果你安装的是8.0版本以下的一定要看注释

  1. [client]
  2. # 设置mysql客户端连接服务器时默认使用的端口
  3. port=3306
  4. # 设置mysql客户端默认字符集
  5. default-character-set=utf8mb4
  6. [mysqld]
  7. # 设置3306端口
  8. port = 3306
  9. # 设置mysql的安装目录
  10. basedir=C:\\Program Files\\mysql-8.0.28-winx64
  11. # 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
  12. # datadir=C:\\Program Files\\mysql-8.0.28-winx64\\data
  13. # 允许最大连接数
  14. max_connections=20
  15. # 服务端使用的字符集默认为utf8mb4
  16. character-set-server=utf8mb4
  17. # 创建新表时将使用的默认存储引擎
  18. default-storage-engine=INNODB
  19. [mysql]
  20. # 设置mysql客户端默认字符集
  21. default-character-set=utf8mb4

创建新表时校对集为utf8mb4_general_ci,mysql8.0默认选择字符集为utf8mb4,校对集为utf8mb4_0900_ai_ci,而mysql5.7没有此校对集,故sql文件导入mysql5.7版本时会报错解决方法就是把校对集改为mysql5.7有的校对集:utf8mb4_general_ci或utf8mb4_bin
collation-server=utf8mb4_general_ci

至于字符集为什么设置成utf8mb4,因为用utf8初始化时,cmd里有[warning]警告,建议我使用utf8mb4.

4、打开cmd,一定要以管理员身份运行,否则mysql不会部署成功的

        //初始化数据库
        mysqld --initialize --console

        //数据库安装
        mysqld install + 你的数据库的名字

例如你起的数据库的名称为mysql8,命令就为mysqld install mysql8,如果不加名字,数据库就为默认的名字“mysql”,其命令就是mysqld install,我这里使用的是默认的名字

        //开启数据库服务
        net start mysql 

        //登录数据库
        mysql -uroot -p"粘贴初始密码"
        这种把密码放在命令行上的方式,能检查密码是否粘贴正确!cmd里会报出警告说“把密码放在命令行上不安全”,这个完全可以忽略!

 回车之后,就是下图这个样子

        //登录进mysql之后修改密码,赋予root用户最高权限(可选)
            ALTER USER 'root'@'localhost' IDENTIFIED BY '新的密码'; 

        ②    flush privileges;

        //退出mysql,再使用自己的密码验证登录一下,看成功了没
        exit

5、那么我们去sqlyog里连接一下去试试看

错误号码2058与MySQL用户认证插件有关。在MySQL 8.0及以上版本中,默认采用caching_sha2_password认证插件,而许多MySQL图形化管理工具或旧版MySQL客户端不支持该插件,因此会导致连接失败并抛出错误号码2058。出现该问题后,有以下两种解决方法:

1、修改MySQL用户认证插件

修改MySQL用户认证插件为mysql_native_password,可以通过执行以下语句实现:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

③刷新一下权限:flush privileges;

其中,'root'@'localhost'是指需要修改密码的用户和主机名,'password'是你的密码。

2、升级MySQL客户端或图形化管理工具

升级到支持caching_sha2_password认证插件的MySQL客户端或图形化管理工具,如最新版的MySQL Workbench、Navicat for MySQL、HeidiSQL等。

重新登一下sqlyog:

6、卸载mysql的命令(谨慎操作),如果哪一天mysql被你搞炸了就比如误删除了mysql里原有的一些数据库或文件而无法撤销时,我们可以选择卸载重新安装mysql,先停止mysql才可以卸载

mysqld -remove 你的数据库的名字

我的数据库的名字为mysql,所以是mysqld -remove mysql

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/289858
推荐阅读
相关标签
  

闽ICP备14008679号