IT虾米网

centos7环境搭建详解

xmjava 2021年11月03日 程序员 239 0
本文章主要介绍了centos7环境搭建,具有不错的的参考价值,希望对您有所帮助,如解说有误或未考虑完全的地方,请您留言指出,谢谢!

安装jdk8和maven:

从华为镜像下载jdk: 
wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz 
 
解压 
cp jdk-8u201-linux-x64.tar.gz /usr/ 
cd /usr/ 
tar -zxvf  jdk-8u201-linux-x64.tar.gz 
 
下载maven: 
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz 
 
解压 
mv apache-maven-3.6.3-bin.tar.gz /usr/ 
tar -zxvf apache-maven-3.6.3-bin.tar.gz 
 

配置环境变量

设置环境变量 
vim /etc/profile 
 
在最后一行增加以下内容,并保存 
export JAVA_HOME=/usr/jdk1.8.0_201 
export JRE_HOME=$JAVA_HOME/jre 
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib 
export MAVEN_HOME=/usr/apache-maven-3.6.3 
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH 
 
生效: 
source /etc/profile 
 
确认是否配置成功,出现以下则说明环境变量配置成功 
[root@iZbp1c8miiew8b9xwft0gmZ ~]# mvn -v 
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) 
Maven home: /usr/apache-maven-3.6.3 
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: /usr/jdk1.8.0_201/jre 
Default locale: zh_CN, platform encoding: UTF-8 
OS name: "linux", version: "3.10.0-1062.1.2.el7.x86_64", arch: "amd64", family: "unix" 
[root@iZbp1c8miiew8b9xwft0gmZ ~]# java -version 
java version "1.8.0_201" 
Java(TM) SE Runtime Environment (build 1.8.0_201-b09) 
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode) 

安装mysql8.0

下载 
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm 
yum -y install mysql80-community-release-el7-3.noarch.rpm 
yum repolist enabled | grep mysql.* 
 
安装mysql server 
yum install mysql-community-server 
 
启动 
systemctl start  mysqld.service 
 
查看状态 
systemctl status mysqld.service 
 
查看初始密码: 
grep "password" /var/log/mysqld.log 
 
登录 
mysql -uroot -p 
 
修改密码 
ALTER USER USER() IDENTIFIED BY 'newPassword'; 
 
报如下错误: 
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 
原因是密码设置太简单了,mysql对密码复杂度进行了校验,建议字母加数字加特殊符号 
 
授权root账号远程访问权限 
use mysql 
update user set host = '%' where user = 'root'; 
select host, user from user; 
 
退出 
quit 
 
重启mysql 
systemctl restart  mysqld.service 
 
结果远程还是不能连接,网上找了另外一个办法: 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'newPassword' WITH GRANT OPTION; 
  
还是报错: 
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'newPassword' WITH GRANT OPTION' at line 1 
网上找资料说原因是mysql8.0后将创建账号和授权分开了:https://dev.mysql.com/doc/refman/5.5/en/grant.html 
但是执行:GRANT ALL ON *.* TO 'root'@'localhost';还是报错 
 
最后解决办法 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; 
刷新 
FLUSH   PRIVILEGES; 
 
注意:中间过程要是出现类似“ERROR 1410 (42000): You are not allowed to create a user with GRANT”之类的错误,执行下FLUSH   PRIVILEGES; 
 

好吧,最后发现自己本地开发是5.6版本的,又把8.0版本的卸载了装了5.6

下载 
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 
rpm -ivh mysql-community-release-el7-5.noarch.rpm 
 
安装 
yum install mysql-community-server 
 
启动 
service mysqld restart 
 
进入(第一次访问没有密码) 
mysql -u root 
 
设置密码 
set password for 'root'@'localhost' = password('newPassword'); 
FLUSH   PRIVILEGES; 
 
重新登录 
mysql -uroot -pnewPassword 
 
设置远程访问 
grant all privileges on *.* to 'root' @'%' identified by 'root'; 
FLUSH   PRIVILEGES; 
 

发布评论
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

java 从字符串中找出所有身份证号码详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。