简介

Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。由于有了Sun 的参与和支持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5支持最新的Servlet 2.4 和JSP 2.0 规范。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。对于一个初学者来说,可以这样认为,当在一台机器上配置好Apache 服务器,可利用它响应HTML(标准通用标记语言下的一个应用)页面的访问请求。实际上Tomcat是Apache 服务器的扩展,但运行时它是独立运行的,所以当你运行tomcat 时,它实际上作为一个与Apache 独立的进程单独运行的。
诀窍是,当配置正确时,Apache 为HTML页面服务,而Tomcat 实际上运行JSP 页面和Servlet。另外,Tomcat和IIS等Web服务器一样,具有处理HTML页面的功能,另外它还是一个Servlet和JSP容器,独立的Servlet容器是Tomcat的默认模式。不过,Tomcat处理静态HTML的能力不如Apache服务器。目前Tomcat最新版本为9.0。
类似于Apache,Nginx等web服务器
nginx和httpd只能处理html等静态文件(jpg),配合PHP就能够处理动态的网页(以.php结尾)、
但Tomcat处理静态HTML的能力不如Nginx、Apache

软件版本选择

JDK下载:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html、

Tomcat下载:http://tomcat.apache.org/

说明:在生产环境下,使用Tomcat安装版本需要同开发协商,Tomcat和JDK版本必须并行(tomcat8<=>jdk8)

Tomcat安装

安装JDK(以后所有涉及到java应用的都需要安装)

JDK->JAVA虚拟机(jvm)>一处编译,处处使用

[root@cairui software]# tar xf jdk-8u161-linux-x64.tar.gz
[root@cairui software]# ls
jdk1.8.0_161
jdk-8u161-linux-x64.tar.gz
[root@cairui software]# mv  jdk1.8.0_161/ /opt/jdk1.8
[root@cairui opt]# ln -s jdk1.8/ jdk
[root@cairui opt]# ll
total 4
lrwxrwxrwx 1 root root    7 Mar 23 12:14 jdk -> jdk1.8/
drwxr-xr-x 8 uucp  143 4096 Dec 20 08:24 jdk1.8
[root@cairui opt]# sed -i.ori '$a export JAVA_HOME=/opt/jdk\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
[root@cairui opt]# source /etc/profile
[root@cairui opt]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
[root@cairui opt]# tail -4 /etc/profile
unset -f pathmunge
export JAVA_HOME=/opt/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

安装Tomcat

[root@cairui software]# tar xf apache-tomcat-8.0.50.tar.gz
[root@cairui software]# ls
apache-tomcat-8.0.50  apache-tomcat-8.0.50.tar.gz  jdk-8u161-linux-x64.tar.gz
[root@cairui software]# mv apache-tomcat-8.0.50 /opt/tomcat-8.0.50
[root@cairui opt]# ln -s tomcat-8.0.50/ tomcat
[root@cairui opt]# ll
total 8
lrwxrwxrwx 1 root root    7 Mar 23 12:14 jdk -> jdk1.8/
drwxr-xr-x 8 uucp  143 4096 Dec 20 08:24 jdk1.8
lrwxrwxrwx 1 root root   14 Mar 23 12:41 tomcat -> tomcat-8.0.50/
drwxr-xr-x 9 root root 4096 Mar 23 12:40 tomcat-8.0.50
[root@cairui opt]# echo 'export TOMCAT_HOME=/opt/tomcat'>>/etc/profile
[root@cairui opt]# source /etc/profile
[root@cairui opt]# useradd tomcat -s /sbin/nologin -M
[root@cairui opt]# chown -R tomcat.tomcat /opt/jdk /opt/tomcat
[root@cairui opt]# ll
total 8
lrwxrwxrwx 1 tomcat tomcat    7 Mar 23 12:14 jdk -> jdk1.8/
drwxr-xr-x 8 uucp      143 4096 Dec 20 08:24 jdk1.8
lrwxrwxrwx 1 tomcat tomcat   14 Mar 23 12:41 tomcat -> tomcat-8.0.50/
drwxr-xr-x 9 root   root   4096 Mar 23 12:40 tomcat-8.0.50

出现下述结果表明配置成功

[root@cairui opt]# /opt/tomcat/bin/version.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /opt/jdk
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.50
Server built:   Feb 7 2018 20:06:05 UTC
Server number:  8.0.50.0
OS Name:        Linux
OS Version:     2.6.32-696.6.3.el6.x86_64
Architecture:   amd64
JVM Version:    1.8.0_161-b12
JVM Vendor:     Oracle Corporation

Tomcat目录结构

[root@cairui tomcat]# tree -L 2
.
├── bin  #用以启动和关闭Tomcat或者其它功能脚本
│   ├── bootstrap.jar
│   ├── catalina.bat
│   ├── catalina.sh  #核心
│   ├── catalina-tasks.xml
│   ├── commons-daemon.jar
│   ├── commons-daemon-native.tar.gz
│   ├── configtest.bat
│   ├── configtest.sh
│   ├── daemon.sh
│   ├── digest.bat
│   ├── digest.sh
│   ├── setclasspath.bat
│   ├── setclasspath.sh
│   ├── shutdown.bat
│   ├── shutdown.sh  #关闭脚本
│   ├── startup.bat
│   ├── startup.sh  #启动脚本
│   ├── tomcat-juli.jar
│   ├── tomcat-native.tar.gz
│   ├── tool-wrapper.bat
│   ├── tool-wrapper.sh
│   ├── version.bat
│   └── version.sh
├── conf  #用以配置Tomcat的XML文件
│   ├── catalina.policy
│   ├── catalina.properties
│   ├── context.xml
│   ├── logging.properties
│   ├── server.xml  #主配置文件
│   ├── tomcat-users.xml  #管理用户配置文件
│   ├── tomcat-users.xsd
│   └── web.xml
├── lib
│   ├── annotations-api.jar
│   ├── catalina-ant.jar
│   ├── catalina-ha.jar
│   ├── catalina.jar
│   ├── catalina-storeconfig.jar
│   ├── catalina-tribes.jar
│   ├── ecj-4.6.3.jar
│   ├── el-api.jar
│   ├── jasper-el.jar
│   ├── jasper.jar
│   ├── jsp-api.jar
│   ├── servlet-api.jar
│   ├── tomcat-api.jar
│   ├── tomcat-coyote.jar
│   ├── tomcat-dbcp.jar
│   ├── tomcat-i18n-es.jar
│   ├── tomcat-i18n-fr.jar
│   ├── tomcat-i18n-ja.jar
│   ├── tomcat-jdbc.jar
│   ├── tomcat-jni.jar
│   ├── tomcat-util.jar
│   ├── tomcat-util-scan.jar
│   ├── tomcat-websocket.jar
│   └── websocket-api.jar
├── LICENSE
├── logs  #web应用程序的日志文件
├── NOTICE
├── RELEASE-NOTES
├── RUNNING.txt
├── temp  #临时目录
│   └── safeToDelete.tmp
├── webapps  #web网页应用程序根目录
│   ├── docs  #Tomcat帮助文档
│   ├── examples  #web应用实例
│   ├── host-manager  #管理
│   ├── manager  #管理
│   └── ROOT  #默认网站根目录
└── work

[root@cairui tomcat]# /opt/tomcat/bin/startup.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /opt/jdk
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@cairui tomcat]# lsof -i:8080  #默认的是8080端口
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    1955 root   48u  IPv4  15539      0t0  TCP *:webcache (LISTEN)

  

查看日志文件

[root@cairui tomcat]# cd /opt/tomcat/logs/
[root@cairui logs]# ll
total 24
-rw-r--r-- 1 root root 6406 Mar 23 13:19 catalina.2018-03-23.log
-rw-r--r-- 1 root root 6406 Mar 23 13:19 catalina.out  #实时记录Tomcat的运行信息(文件越来越大,需要定时清理)
-rw-r--r-- 1 root root    0 Mar 23 13:19 host-manager.2018-03-23.log
-rw-r--r-- 1 root root  459 Mar 23 13:19 localhost.2018-03-23.log
-rw-r--r-- 1 root root  755 Mar 23 13:21 localhost_access_log.2018-03-23.txt
-rw-r--r-- 1 root root    0 Mar 23 13:19 manager.2018-03-23.log
[root@cairui logs]# tail catalina.out
23-Mar-2018 13:19:04.226 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.0.50/webapps/manager has finished in 100 ms
23-Mar-2018 13:19:04.226 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.0.50/webapps/host-manager
23-Mar-2018 13:19:04.303 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.0.50/webapps/host-manager has finished in 77 ms
23-Mar-2018 13:19:04.308 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.0.50/webapps/examples
23-Mar-2018 13:19:05.000 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.0.50/webapps/examples has finished in 692 ms
23-Mar-2018 13:19:05.000 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat-8.0.50/webapps/docs
23-Mar-2018 13:19:05.037 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat-8.0.50/webapps/docs has finished in 37 ms
23-Mar-2018 13:19:05.048 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
23-Mar-2018 13:19:05.078 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
23-Mar-2018 13:19:05.098 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2793 ms

通过web管理Tomcat

定义web页面用户名以及密码

[root@cairui logs]# tail -4 /opt/tomcat/conf/tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
</tomcat-users>重启:
[root@cairui logs]# /opt/tomcat/bin/shutdown.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /opt/jdk
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
[root@cairui logs]# /opt/tomcat/bin/startup.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /opt/jdk
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.[root@cairui logs]# lsof -i|grep java
java      7947 root   48u  IPv4  20525      0t0  TCP *:webcache (LISTEN)
java      7947 root   53u  IPv4  20529      0t0  TCP *:8009 (LISTEN)
java      7947 root   68u  IPv4  20540      0t0  TCP localhost:mxi (LISTEN)

Tomcat主配置文件

[root@cairui logs]# cat /opt/tomcat/conf/server.xml
<?xml version='1.0' encoding='utf-8'?>
<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may notdefine subcomponents such as "Valves" at this level.Documentation at /docs/config/server.html-->
<Server port="8005" shutdown="SHUTDOWN"><Listener className="org.apache.catalina.startup.VersionLoggerListener" /><!-- Security listener. Documentation at /docs/config/listeners.html<Listener className="org.apache.catalina.security.SecurityListener" />--><!--APR library loader. Documentation at /docs/apr.html --><Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /><!-- Prevent memory leaks due to use of particular java/javax APIs--><Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /><Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /><Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /><!-- Global JNDI resourcesDocumentation at /docs/jndi-resources-howto.html--><GlobalNamingResources><!-- Editable user database that can also be used byUserDatabaseRealm to authenticate users--><Resource name="UserDatabase" auth="Container"type="org.apache.catalina.UserDatabase"description="User database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml" /></GlobalNamingResources><!-- A "Service" is a collection of one or more "Connectors" that sharea single "Container" Note:  A "Service" is not itself a "Container",so you may not define subcomponents such as "Valves" at this level.Documentation at /docs/config/service.html--><Service name="Catalina"><!--The connectors can use a shared executor, you can define one or more named thread pools--><!--<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"maxThreads="150" minSpareThreads="4"/>--><!-- A "Connector" represents an endpoint by which requests are receivedand responses are returned. Documentation at :Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)Java AJP  Connector: /docs/config/ajp.htmlAPR (HTTP/AJP) Connector: /docs/apr.htmlDefine a non-SSL/TLS HTTP/1.1 Connector on port 8080--><Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" /><!-- A "Connector" using the shared thread pool--><!--<Connector executor="tomcatThreadPool"port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />--><!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443This connector uses the NIO implementation that requires the JSSEstyle configuration. When using the APR/native implementation, theOpenSSL style configuration is required as described in the APR/nativedocumentation --><!--<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"maxThreads="150" SSLEnabled="true" scheme="https" secure="true"clientAuth="false" sslProtocol="TLS" />--><!-- Define an AJP 1.3 Connector on port 8009 --><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /><!-- An Engine represents the entry point (within Catalina) that processesevery request.  The Engine implementation for Tomcat stand aloneanalyzes the HTTP headers included with the request, and passes themon to the appropriate Host (virtual host).Documentation at /docs/config/engine.html --><!-- You should set jvmRoute to support load-balancing via AJP ie :<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">--><Engine name="Catalina" defaultHost="localhost"><!--For clustering, please take a look at documentation at:/docs/cluster-howto.html  (simple how to)/docs/config/cluster.html (reference documentation) --><!--<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>--><!-- Use the LockOutRealm to prevent attempts to guess user passwordsvia a brute-force attack --><Realm className="org.apache.catalina.realm.LockOutRealm"><!-- This Realm uses the UserDatabase configured in the global JNDIresources under the key "UserDatabase".  Any editsthat are performed against this UserDatabase are immediatelyavailable for use by the Realm.  --><Realm className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm><Host name="localhost"  appBase="webapps"unpackWARs="true" autoDeploy="true"><!-- SingleSignOn valve, share authentication between web applicationsDocumentation at: /docs/config/valve.html --><!--<Valve className="org.apache.catalina.authenticator.SingleSignOn" />--><!-- Access log processes all example.Documentation at: /docs/config/valve.htmlNote: The pattern used is equivalent to using pattern="common" --><Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="localhost_access_log" suffix=".txt"pattern="%h %l %u %t "%r" %s %b" /></Host></Engine></Service>
</Server>

[root@cairui logs]# cat /opt/tomcat/conf/server.xml | egrep -v "^$| <\!|<\!"
<?xml version='1.0' encoding='utf-8'?>Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->define subcomponents such as "Valves" at this level.Documentation at /docs/config/server.html-->
<Server port="8005" shutdown="SHUTDOWN"><Listener className="org.apache.catalina.startup.VersionLoggerListener" /><Listener className="org.apache.catalina.security.SecurityListener" />--><Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /><Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /><Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /><Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />Documentation at /docs/jndi-resources-howto.html--><GlobalNamingResources>UserDatabaseRealm to authenticate users--><Resource name="UserDatabase" auth="Container"type="org.apache.catalina.UserDatabase"description="User database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml" /></GlobalNamingResources>a single "Container" Note:  A "Service" is not itself a "Container",so you may not define subcomponents such as "Valves" at this level.Documentation at /docs/config/service.html-->#<Service服务组件><Service name="Catalina"><Executor name="tomcatThreadPool" namePrefix="catalina-exec-"maxThreads="150" minSpareThreads="4"/>-->and responses are returned. Documentation at :Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)Java AJP  Connector: /docs/config/ajp.htmlAPR (HTTP/AJP) Connector: /docs/apr.htmlDefine a non-SSL/TLS HTTP/1.1 Connector on port 8080--><Connector port="8080" protocol="HTTP/1.1"  #connector接收用户请求,类似于httpd的listen配置监听端口,port指定服务器需要创建的端口connectionTimeout="20000"redirectPort="8443" /><Connector executor="tomcatThreadPool"port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />-->This connector uses the NIO implementation that requires the JSSEstyle configuration. When using the APR/native implementation, theOpenSSL style configuration is required as described in the APR/nativedocumentation --><Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"maxThreads="150" SSLEnabled="true" scheme="https" secure="true"clientAuth="false" sslProtocol="TLS" />--><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />every request.  The Engine implementation for Tomcat stand aloneanalyzes the HTTP headers included with the request, and passes themon to the appropriate Host (virtual host).Documentation at /docs/config/engine.html --><Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">--><Engine name="Catalina" defaultHost="localhost">/docs/cluster-howto.html  (simple how to)/docs/config/cluster.html (reference documentation) --><Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>-->via a brute-force attack --><Realm className="org.apache.catalina.realm.LockOutRealm">  #realm表示存放用户名,密码以及role的数据库resources under the key "UserDatabase".  Any editsthat are performed against this UserDatabase are immediatelyavailable for use by the Realm.  --><Realm className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm>#host表示一个虚拟机,name指定主机名,appbase应用程序目录<Host name="localhost"  appBase="webapps"unpackWARs="true" autoDeploy="true">Documentation at: /docs/config/valve.html --><Valve className="org.apache.catalina.authenticator.SingleSignOn" />-->Documentation at: /docs/config/valve.htmlNote: The pattern used is equivalent to using pattern="common" --><Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="localhost_access_log" suffix=".txt"pattern="%h %l %u %t "%r" %s %b" /></Host></Engine></Service>
</Server>

web站点部署

方法一:即直接将程序目录放在webapps下

方法二:即用开发工具将程序打包成war包。然后上传到webapps下

搭建Jpress->java版本的wordpress

下载地址:https://github.com/JpressProjects/jpres

安装配置数据库

[root@cairui opt]# rpm -qa | grep mysql*
[root@cairui opt]# yum install mysql -y
[root@cairui opt]# yum install mysql-server -y
[root@cairui opt]# yum install mysql-devel -y
[root@cairui opt]# /etc/init.d/mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OKTo start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h cairui password 'new-password'Alternatively you can run:
/usr/bin/mysql_secure_installationwhich will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script![  OK  ]
Starting mysqld:                                           [  OK  ]
[root@cairui opt]# /usr/bin/mysqladmin -u root password '123456'
[root@cairui opt]# source /etc/profile
[root@cairui opt]# mysql -uroot -p123456

  

mysql> create database jpress default character set utf8;
Query OK, 1 row affected (0.00 sec)mysql> grant all on jpress.* to jpress@'localhost' identified by 'jpress';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  

转载于:https://www.cnblogs.com/caicairui/p/8630719.html

Tomcat企业级应用相关推荐

  1. nginx+tomcat 企业级jsp项目部署

    项目实验思路及重点内容(步骤及重难知识点) 1.环境: 主机 功能介绍 ip地址 主要软件 nginx1 nginx高可用节点,同时作为反向代理服务 192.168.200.202 nginx+kee ...

  2. Jenkins+Maven+Gitlab+Tomcat 自动化构建打包、部署

    一.环境需求 本帖针对的是Linux环境,Windows或其他系统也可借鉴.具体只讲述Jenkins配置以及整个流程的实现. 1.JDK(或JRE)及Java环境变量配置,我用的是JDK1.8.0_1 ...

  3. nginxgrafana监控面板显示nodatatoshow

    grafana 怎么用nginx 解决方法如下:1.编辑vi /etc/ld.so.conf如果是非root权限帐号登录,使用 sudo vi /etc/ld.so.conf添加上python2.7的 ...

  4. Phython基础语法知识点汇集

    Phython基础语法知识点汇集 原创 辰兮要努力 最后发布于2020-03-29 18:42:24 阅读数 3506 收藏 原力计划 发布于2020-03-29 18:42:24 分类专栏: Phy ...

  5. 企业级架构apache/PHP/tomcat架构应用实战-高俊峰-专题视频课程

    企业级架构apache/PHP/tomcat架构应用实战-4807人已学习 课程介绍         本课程主要介绍企业级常见的apache/PHP/tomcat常见应用架构的使用经验和技巧. 课程收 ...

  6. 专题篇四:Linux企业级CICD持续集成交付发布(终极实战部署:gitlab++jenkins+web(tomcat)+webbook自动发布)

    4,企业级CI/CD 持续集成/交付/发布 实验一:github+jenkins+web(tomcat) 构建的时候 网络连接超时(正常现象) githud仓库地址1.安装对应的插件(jenkins) ...

  7. 企业级应用中间件管理与维护实战培训(WebLogic、WebSphere、Tomcat)

    风哥企业级应用中间件管理与维护实战培训专题,风哥本专题共9套课程涉及WebLogic运维管理与集群.WebSphere项目与集群.Tomcat集群与管理优化内容,本系列课程项目介绍: ​ 课程内容: ...

  8. JAVA企业级应用TOMCAT实战

    1. Tomcat简介 Tomcat是Apache软件基金会(ApacheSoftware Foundation)的Jakarta 项目中的一个核心项目,由Apache.Sun和其他一些公司及个人共同 ...

  9. 【微信小程序企业级开发教程】如何搭建服务器(tomcat)后台

    文章目录 1 条件 2 步骤 2.1 获取AppID 2.2 服务器.域名(需备案).ssl证书(可免费申请) 2.3 域名备案 2.4 SSL证书(申请与安装配置) 3 微信公众平台中配置域名信息 ...

最新文章

  1. 《强化学习周刊》第28期:UNCC提出全新脑-机交互学习模式:内在互动强化学习...
  2. codeforces 401D. Roman and Numbers 数位dp
  3. ABAP代码检查的注意事项有哪些
  4. pytorch使用清华源安装仍失败解决方案
  5. webpack手动构建vue和vue-cli构建使用 px2rem-loader ,全局自动转换px单位,让自适应来的更简单点!...
  6. python写采集程序_Python爬虫小说采集程序
  7. linux下载git并为git配置连接ssh
  8. CC26x2R1笔记(8)CCS9.2 cc26xx环境的搭建
  9. ODL(OpenDayLight)Yang UI界面下发流表(ODL+mininet)
  10. Ubuntu下阅读CHM格式的文档
  11. supermap leaflet (二) 运动点及轨迹
  12. pandas之美国各州人口分析
  13. 视频压缩【亲测可用】
  14. 使用VC++6.0时出现error spawning cl.exe解决方法
  15. 【回溯法】八皇后问题
  16. python+windows11下切换输入法
  17. php 正则匹配img标签中的自定义属性值
  18. 微信小程序图片在刚进入页面的时候会被拉扯变形的解决办法
  19. 百度官方解答百度快照的4大问题
  20. 米兰理工大学的计算机工程怎么样,米兰理工大学专业设置有哪些?

热门文章

  1. 120xa正反转参数_RFID的软件SOPAS参数设置
  2. python3高性能网络编程_Python3 网络编程
  3. 解决SQL注入与XSS攻击
  4. 线性表C语言locate和ETget,线性表(数据结构重难点讲解)
  5. plsql连接oracle后查询报错,plsql developer连接oracle 12.2报错 ora-28040 No matching authentication protocol...
  6. catia目录编辑器使用教程_如何去编辑数学公式?公式编辑器使用教程
  7. linux中find命令的35个实际例子
  8. python遗传算法最短路径问题有几种类型_遗传算法求最短路径 - osc_tn8uhjgi的个人空间 - OSCHINA - 中文开源技术交流社区...
  9. stm32 iic接口 进入busy_STM32通过IIC接口读取JY61模块MPU6050陀螺仪芯片数据核心程序...
  10. android menu分割线,给 NavigationView 的Menu的分割线 设置高度和颜色