查看软件安装位置:
ps -ef|grep mysql 或
whereis mysql
1.安装jdk
利用yum源来安装jdk(此方法不需要配置环境变量)
查看yum库中的java安装包 yum -y list java
安装需要的jdk版本的所有java程序 yum -y install java-1.8.0-openjdk
(安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64)
2.安装mysql
yum下载网址为:https://dev.mysql.com/downloads/repo/yum/
找到Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package,单击后面的Download,
在新的页面中单击最下面的No thanks, just start my download.就可以下载到yum源了。
1)安装MySQL YUM资源库
[root@kevin ~]# yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2)安装MySQL 5.7
[root@kevin ~]# yum install -y mysql-community-server
3)启动MySQL服务器和MySQL的自动启动
// 启动MySQL服务器
[root@kevin ~]# systemctl start mysqld.service
// MySQL的自动启动
[root@kevin ~]# systemctl enable mysqld.service
-- 如果启动后出现
Failed to start mariadb.service: Unit not found.
需要先安装这个
yum install -y mariadb-server
4)密码问题
由于MySQL从5.7开始不允许首次安装后使用空密码进行登录!为了加强安全性,系统会随机生成一个密码以供管理员首次登录使用,
这个密码记录在/var/log/mysqld.log文件中,使用下面的命令可以查看此密码:
[root@kevin ~]# cat /var/log/mysqld.log|grep 'A temporary password'
2018-01-24T02:32:20.210903Z 1 [Note] A temporary password is generated for root@localhost: DOqInortw9/<
最后一行冒号后面的部分DOqInortw9/<就是初始密码。
使用此密码登录MySQL:
[root@kevin ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.21
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
使用随机生产的密码登录到服务端后,必须马上修改密码,不然会报如下错误:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
有两种方法解决上面的报错(如下的123456是修改后的密码):
mysql> set password=password("123456");
或者
mysql> alter user 'root'@'localhost' identified by '123456';
刷新权限
mysql> flush privileges;
===============================================================================================
如果上面在执行set password=password("123456");命令后出现下面的报错:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决办法:
这个与Mysql 密码安全策略validate_password_policy的值有关,validate_password_policy可以取0、1、2三个值:
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary
默认的数值是1,符合长度,且必须含有数字,小写或大写字母,特殊字符。
所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。
必须修改两个全局参数:
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
修改上面两个参数后,就可以解决这个报错了。
=======================================================================================================
注意一点:
mysql5.7之后的数据库里mysql.user表里已经没有password这个字段了,password字段改成了authentication_string。
所以修改密码的命令如下:
mysql> update mysql.user set authentication_string=password('kevin@123') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
=======================================================================================================
查看mysql版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.21 |
+-----------+
1 row in set (0.00 sec)
mysql>
=======================================================================================================
修改mysql5.7的编码由latin1为utf8
默认编码:
mysql> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.01 sec)
调整操作:
[root@kevin ~]# cat /etc/my.cnf
......
[mysqld]
......
character-set-server=utf8 //注意这个不能写成default-character-set=utf8,否则会导致5.7版本mysql无法打开
[client]
default-character-set=utf8
[root@kevin~]# systemctl restart mysqld.service
[root@kevin~]# mysql -p
......
mysql> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| 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.01 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql>
----------------------------------------------------------
systemctl start mysqld #启动mysqld
systemctl stop mysqld #停止mysqld
systemctl restart mysqld #重启mysqld
systemctl enable mysqld #设置开机启动
systemctl status mysqld #查看 MySQL Server 状态
3.安装Tomcat
访问官网:https://tomcat.apache.org
第一种方式:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.41/bin/apache-tomcat-8.5.41.tar.gz
解压tomcat8压缩包
[root@localhost soft]# tar -zxvf apache-tomcat-8.5.23.tar.gz
移动到/usr/local目录
[root@localhost soft]# mv apache-tomcat-8.5.23 /usr/local/tomcat
防火墙开启8080端口
[root@localhost /]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
[root@localhost /]# firewall-cmd --reload
启动tomcat8
[root@localhost /]# /usr/local/tomcat/bin/startup.sh
第二种方式:
yum install tomcat
4.安装nginx
第一种方式:
yum info nginx
yum install nginx
安装完成后nginx就已经启动了,可以查看进程:
ps -ef|grep nginx
使用:whereis nginx 查看nginx默认安装位置
以下是Nginx的默认路径:
(1) Nginx配置路径:/etc/nginx/
(2) PID目录:/var/run/nginx.pid
(3) 错误日志:/var/log/nginx/error.log
(4) 访问日志:/var/log/nginx/access.log
(5) 默认站点目录:/usr/share/nginx/html
第二种方式:通过手动下载安装包解压安装
1.下载nginx包。
[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
2.复制包到你的安装目录
[root@localhost ~]# cp nginx-1.10.1.tar.gz /usr/local/
3.解压
[root@localhost ~]# tar -zxvf nginx-1.10.1.tar.gz
[root@localhost ~]# cd nginx-1.10.1
4.启动nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
5.查看版本s
[root@localhost ~]# nginx -v
6.url访问nginx localhost或127.0.0.1
网友评论