安装jdk1.8
- 下载jdk
- cd /usr/local mkdir java
- 把下载的移动到java目录下 cd java
- 解压 tar -zxvf jdk-8u201-linux-x64.tar.gz 并删除 rm jdk-8u201-linux-x64.tar.gz
- 重命名文件 mv jdk1.8.0_201 jdk1.8
- pwd 复制路径
- 配置环境变量
- java -version
export JAVA_HOME=/usr/local/java/jdk1.8 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
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)
安装tomcat
- 下载tomcat
- cd /usr/local mkdir tomcat
- 移动到该文件夹 并解压 tar -zxvf apache-tomcat-8.5.45.tar.gz
- rm apache-tomcat-8.5.45.tar.gz
- cd apache-tomcat-8.5.45/bin/ 执行 ./startup.sh
- 通过ip+8080端口访问 出现猫就好了
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.45 Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.45 Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.45/temp Using JRE_HOME: /usr/local/java/jdk1.8 Using CLASSPATH: /usr/local/tomcat/apache-tomcat-8.5.45/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.45/bin/tomcat-juli.jar Tomcat started.
安装mysql5.7
- 下载mysql5.7版本
- 移动到/usr/local 下面 并解压 tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
- 修改文件名 mv mysql-5.7.27-linux-glibc2.12-x86_64 mysql
- 添加用户组,用专门管理mysql,提高安全 -> groupadd mysql(新建组) -> useradd -r -g mysql mysql(新建用户)
- 修改mysql目录权限 进入mysql根目录 cd /usr/local/mysql/(如果在这个下面忽略) -> chown -R mysql:mysql ./(修改拥有者为mysql用户)
- 配置mysql服务 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql(将mysql/support-files下的mysql.server 复制到 /etc/init.d/下并自定义为mysql) -> vi /etc/init.d/mysql -> 修改 basedir=/usr/local/mysql datadir=/usr/local/mysql/data
- 编辑配置文件 cd /etc ->rm -rf my.cnf ->vi my.cnf
- 执行启动 ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
出现如下错误
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
yum -y install numactl.x86_64
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
yum -y install libaio
成功后显示
2021-03-08T13:09:59.034830Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-03-08T13:09:59.209562Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-03-08T13:09:59.280696Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 95e801c1-800f-11eb-bf00-00163e12b421.
2021-03-08T13:09:59.284772Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-03-08T13:09:59.285369Z 1 [Note] A temporary password is generated for root@localhost: 2J4YyA&=.Tbs(一定要记下来)
my.cnf
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port = 3306
default-character-set=utf8
[mysqld]
# 一般配置选项
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character-set-server=utf8
default_storage_engine = InnoDB
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
基础配置完成
- 启动服务service mysql start
- ./mysql -uroot -p 输入密码进入
- set password=password('新密码');
- 设置远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '访问密码';
设置开机启动和环境变量
- 查看自启服务列表 chkconfig --list
- 添加mysql服务到自启服务 chkconfig --add mysql
- 设置自启 chkconfig mysql on
- 环境变量
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin