Installing JDK, Tomcat and MySQL in Linux

Time:2021-1-23

Wen Pingge date 20201010

Environment introduction

This article is mainly to practice the Linux environment to install software records, focusing on the operation of Linux.
Operating environment:

  • MacOS 10.15.7
  • VMware fusion professional 11.5.6(Last year’s double 11 took advantage of the activity to buy a genuine, 500 + RMB, refreshing
  • Zentermlite version 4.1.0 (21)

Software version:

  • Linux:CentOS-8.2.2004-x86_ 64, download address: click me to jump
  • JDK: jdk-8u261-linux-x64, download address: click me to jump
  • Tomcat: apache-tomcat-7.0.106, download address: click me to jump
  • MySQL: MySQL 8.0, which is installed online. See the following steps for details

Step 1 installing Linux

The steps of installing Linux in the virtual machine are not demonstrated in detail. 2G of memory and 20g of disk are recommended. The others can be installed directly. The key point is the installation of software in the Linux environment. If you have any problems, you can Google Baidu or leave a message.

Step 2 install and configure JDK

After Linux is installed,Turn on the network card(for details of how to open it, click “I jump”), and then you can use zentermlite to connect to Linux for remote access operation. Of course, you can operate directly in Linux.

2.1 upload and unzip JDK compressed files

Zentermlite can transfer files directly to the Linux system by default, with shortcut keyscommand + z, upload the downloaded JDK package to CentOS:
Installing JDK, Tomcat and MySQL in Linux
utilizetarCommand decompression:

    tar -zxvf jdk-8u261-linux-x64.tar.gz 

utilizemvCommand to move a folder to/usr/local/jdk1.8

    mv jdk1.8.0_261/ /usr/local/jdk1.8

2.2 configure environment variables

In Linux, / etc / profile is the configuration file of environment variablesvimCommand to modify the file:
In command mode, press Shift + G to jump to the end of the file, and press I to edit

    export JAVA_HOME=/usr/local/jdk1.8
    export PATH=$JAVA_HOME/bin:$PATH

As shown in the figure:
Installing JDK, Tomcat and MySQL in Linux

2.3 parsing profile configuration file

utilizesourceCommand to parse the profile file

    source /etc/profile

Note: if not resolved, the system configuration must be restarted to take effect. As long as the parsing doesn’t need to be restarted,But only the current user session is valid

2.4 verify whether JDK is configured successfully

Use:java -versionCheck if JDK configuration is successful:
Installing JDK, Tomcat and MySQL in Linux

Step 3 installing and configuring Tomcat

3.1 upload and unzip Tomcat compressed file

The upload and decompression steps are the same as JDK. Finally, move the unzipped file to / usr / local / tomcat7 directory, and CD it to this directory to view:
Installing JDK, Tomcat and MySQL in Linux

3.2 start Tomcat

Enter the bin directory under the Tomcat directory and execute the./startup.shCommand to start:
Installing JDK, Tomcat and MySQL in Linux

3.3 turn off the firewall

Use the following command to close the firewall:

    systemctl stop firewalld

Note: at this time, if the system is restarted, the firewall will restart. You can use the following command to make the firewall not open even if the system is restarted:

    systemctl disable firewalld

3.4 check whether Tomcat can be accessed

Open a browser in the MacOS environment and enter the IP: 8080 of CentOS to see if it can be accessed
Installing JDK, Tomcat and MySQL in Linux

Step 4 install and configure MySQL

4.1 download image library

Jump to the directory where the compressed file was uploaded, and download the image library with the following command:

    wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

4.2 install image library

Use the following command to install the image library:

    rpm -ivh mysql80-community-release-el8-1.noarch.rpm 

The results are as follows
Installing JDK, Tomcat and MySQL in Linux

4.3 install MySQL service

Use the following command to install MySQL service:

    yum install -y mysql-server

-yIt means that the installation process is not interactive, that is, you don’t need to confirm with me whether to install

The following screen appears. The code is installed successfully:
Installing JDK, Tomcat and MySQL in Linux

4.4 setting self starting

Use the following command to set the MySQL service to boot automatically:

    systemctl enable mysqld

4.5 start MySQL service

Use the following command to start MySQL service:

    systemctl start mysqld

4.6 test whether MySQL starts successfully

Use the following command to test whether MySQL starts successfully:

    mysql -uroot -p

If you want to enter the password, just press enter. The result is as follows:
Installing JDK, Tomcat and MySQL in Linux

4.7 change the root password

Use the following command to use MySQL database

    use mysql

Continue to use the following commands to enter commands on the MySQL command line to change the password. Finally, the content in the single quotation mark is the root password, which can be defined by yourself.

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

4.7 setting Mysql to allow any client to access

Use the following command to modify the root user to run any client access:

     update user set host='%' where user='root';

The results are as follows
Installing JDK, Tomcat and MySQL in Linux

Use the following command to refresh the permissions:

    flush privileges;

Exit the MySQL command line with the following command:

    exit;

Restart the MySQL service with the following command. If the permissions are not refreshed, the service must be restarted to take effect

    systemctl restart mysqld

4.8 test for successful connection

Open Navicat in the MacOS environment, and enter the IP of CentOS and the root user name and password of MySQL, as shown in the figure below:
Installing JDK, Tomcat and MySQL in Linux
Click “test connection”. If the connection is successful, it means that MySQL is installed and configured successfully.