最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
centos配置meysql,tomcat环境步骤详解
时间:2022-06-30 20:46:10 编辑:袖梨 来源:一聚教程网
安装JAVA环境
1.下载JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.将JDK文件上传到服务器的/usr/local/download目录下
上传命令: scp jdk-8u111-linux-x64.rpm root@:/usr/local/download
3.安装jdk
命令:rpm -ivh jdk-8u111-linux-x64.rpm
4.安装MySQL
下载
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
安装:
添加 MySQL Yum Repository
yum localinstall mysql-community-release-el7-5.noarch.rpm
验证下是否添加成功
yum repolist enabled | grep "mysql.*-community.*"
- 选择要启用 MySQL 版本
yum repolist all | grep mysql
可以看到 5.5, 5.7 版本是默认禁用的,因为现在最新的稳定版是 5.6
[root@bogon software]# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 14
mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用
mysql-tools-community/x86_64 MySQL Tools Community 启用: 17
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sourc 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 启用: 139
mysql56-community-source MySQL 5.6 Community Server - Sourc 禁用
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Develop 禁用
mysql57-community-dmr-source MySQL 5.7 Community Server Develop 禁用
```
- 可以通过类似下面的语句来启动某些版本
```
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
```
注意: 任何时候,只能启用一个版本。
- 查看当前的启动的 MySQL 版本
```
yum repolist enabled | grep mysql
[root@bogon software]# yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 14
mysql-tools-community/x86_64 MySQL Tools Community 17
mysql56-community/x86_64 MySQL 5.6 Community Server 139
```
## 通过 Yum 来安装 MySQL
yum install mysql-community-server
Yum 会自动处理 MySQL 与其他组件的依赖关系:
- 执行
rpm -qi mysql-community-server.x86_64 0:5.6.24-3.el7
## 启动和关闭 MySQL Server
1 启动 MySQL Server
systemctl start mysqld
2 查看 MySQL Server 状态
systemctl status mysqld
3 关闭 MySQL Server
systemctl stop mysqld
4. 测试是否安装成功
mysql
## 防火墙设置
1. 远程访问 MySQL, 需开放默认端口号 3306.
- firewall-cmd
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=3306/udp
使最新的防火墙设置规则生效。
firewall-cmd --reload
## 开机自起
1. 查看 MySQL 服务是否开机启动
[root@localhost ~]# systemctl is-enabled mysql.service;echo $?
enabled
0
如果是 enabled 则说明是开机自动,如果不是,执行
chkconfig --levels 235 mysqld on
## 设置字符集
修改 /etc/my.cnf 文件,添加字符集的设置
[mysqld]
character set server = utf8
[mysql] default-character-set = utf8
重启 MySQL ,可以看到字符集已经修改了
mysql> SHOW VARIABLES LIKE 'character%'
-> ; +--------------------------+----------------------------+ | Variable name | Value | +--------------------------+----------------------------+ | character set client | utf8 | | character set connection | utf8 | | character set database | utf8 | | character set filesystem | binary | | character set results | utf8 | | character set server | utf8 | | character set system | utf8 | | character sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
# 安装tomcat
1.下载tomcat http://tomcat.apache.org/
2. 将tomcat文件上传到服务器,并解压
scp apache-tomcat-9.0.0.M11.zip [email protected]:/usr/local/download
如果没有安装unzip命令,先安装 yum install unzip
解压tomcat并重命名
unzip apache-tomcat-9.0.0.M11.zip mv apache-tomcat-9.0.0.M11.zip ../tomcat
3.启动端口号 8080
firewall-cmd --zone=public --add-port=8080/tcp --permanent
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效
//重启防火墙 firewall-cmd --reload
出现firewalld is not running的报错,用以下命令将firewalld起起来即可
systemctl start firewalld
systemctl enable firewalld
4.启动tomcat
进入到tomcat的bin目录,修改所有后缀名为.sh的权限
cd /usr/local/tomcat/bin
chmod u+x *.sh
//启动tomcat服务 ./startup.sh
//停止tomcat服务 ./shutdown.sh
```
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20