本文转自:http://blog.csdn.net/zhouygjp/article/details/48574823

CentOS6.6 安装JDK8+TOMCAT8+MYSQL

1,下载好下面的安装包。

jdk-8u60-linux-x64.rpm
apache-tomcat-8.0.26.tar

网址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
http://tomcat.apache.org/download-80.cgi

2,在CentOS6.6 的/opt/下建个tools目录,把下载好的安装包用FTP上传到/opt/tools/下。

3,安装JDK

#java -version
#rpm -qa | grep java
#rpm -qa | grep jdk

如果有openjdk的话,卸载掉。
如:Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

#rpm -e –nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
#yum -y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

安装:

#cd /opt/tools/
#rpm -ivh jdk-8u60-linux-x64.rpm

确认一下

#java -version
java version “1.8.0_60”
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

4,安装TOMCAT

#cd /opt/tools/
#tar xzvf apache-tomcat-8.0.26.tar.gz
#mv apache-tomcat-8.0.26 /opt/tomcat/
#./opt/tomcat/bin/startup.sh

确认一下
http://xxx.xxx.xxx.xxx:8080能访问就成功了。

5,安装MYSQL

查看是否有已经安装的。

#rpm -qa | grep mysql

有已经安装的。
MySQL-libs-5.1.73-3.el6_5.x86_64

先卸载

#yum -y remove mysql mysql-libs-5.1.73-3.el6_5.x86_64

查看可下载的版本

#yum list | grep mysql

安装mysql-server

#yum install -y mysql-server mysql mysql-deve

可以通过如下命令,查看刚安装好的mysql-server的版本

#rpm -qi mysql-server

启动和再启动

#service mysqld start
#service mysqld restart

设置mysql服务开机自动启动

#chkconfig –list | grep mysqld
#chkconfig mysqld on
#chkconfig –list | grep mysqld

设置root账号密码

#mysqladmin -u root password ‘123456’

测试数据库

#mysql -u root -p

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| test |
+——————–+
3 rows in set (0.00 sec)

设置外网

查看3360端口

#netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 24197/mysqld

对外开放3360端口

#iptables -I INPUT -p tcp -m state –state NEW -m tcp –dport 3306 -j ACCEPT
#iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:3306

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

新建数据库

#mysql -u root -p
mysql> CREATE DATABASE demo_db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| demo_db |
| mysql |
| test |
+——————–+
4 rows in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> grant all on demo_db .* to ‘demouser’@’%’ identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye

然后在外网就可以用MYSQL数据库工具(如Navicat )访问MYSQL数据库了。