Installation of common tools under Linux

1. JDK installation

  1. First create it in the /home directory, the mytest folder
  2. Then use a file transfer tool such as WinSCP to drag and drop the Linux version of the JDK under Windows to the /home/mytest folder under Linux
    Insert picture description here
    Insert picture description here
  3. The configuration of environment variables is
    ① used by default.
    Insert picture description here
    ② The profile file in the /etc directory is added at the end:
export JAVA_HOME=/usr/local/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar

如果担心文件修改错误,可以先备份文件, 执行cp 命令
③ profile file modified to perform source /etc/profileto make the above configurations take effect

The source command is usually used to re-execute the newly modified initialization file to make it effective immediately without having to log out and log in again.

Syntax: source file name
For example: source /etc/profile

Insert picture description here

2. Tomcat installation

  1. First create it in the /home directory, the mytest folder
  2. Then use a file transfer tool such as WinSCP to drag and drop the Linux version of Tomcat under Windows to the /home/mytest folder under Linux
    Insert picture description here
  3. tar -xvzf apache-tomcat-9.0.0.M26.tar.gz -C /usr/local
    Unzip with command

3. MySQL installation

  1. The first three steps refer to the installation of Tomcat and JDK under Linux
  2. Check whether the mariadb database is installed in the system. Check whether the mariadb database
    is installed in linux. The mariadb database is a branch of mysql. It is free and open source. There will be conflicts between mariadb and msyql. First, check that mariadb is installed and uninstall it.

Check command: yum list installed | grep mariadb
Insert picture description here

  1. Uninstall mariadb (try to finish before decompression)

If the mariadb database is installed in linux, uninstall it first. The mariadb database may conflict with the installation of mysql.

Execute the command: yum -y remove mariadb-libs.x86_64

Among them, mariadb-libs.x86_64 is the mariadb software package searched in step 2. It may be different for different machines. Confirm the deletion of the -y parameter.
Insert picture description here

  1. Wait for the uninstallation to complete: prompt Complete, uninstallation is complete
    Insert picture description here
  2. Rename the uncompressed MySQL'
    Insert picture description here
  3. Create a data folder The data
    data folder is used by mysql to store database files, and the table data of the database are placed in the data directory.

There is no data directory by default, you can create a data directory manually, create a data folder under the mysql-5.7.18 folder directory, switch to the mysql-5.7.18 directory, and execute the create folder command

Command: mkdir data

Insert picture description here

  1. Create a user to execute the mysqld command
    Create a mysql user, used to execute the MySQL command mysqld, this command is used to initialize the basic information of msyql.

Execute the command: useradd mysql

Insert picture description here

  1. Initialize MySQL
    Use the mysqld command of mysql to initialize the basic information of the database. Switch to the mysql-5.7.18/bin directory to execute.
    Command (note that the following command is executed on one line):

./mysqld --initialize --user=mysql
–datadir=/usr/local/mysql-5.7.18/data
–basedir=/usr/local/mysql-5.7.18

上面的命令是在一行执行的
Insert picture description here
Parameter Description:

-Initialize Initialize mysql, create mysql root, and randomly generate passwords. Remember the password, log in to msyql to use.
–User Linux user name for executing msyqld command
–datadir: The storage location of mysql data files, the directory location refers to the settings of this machine.
-Basedir: The directory of the msyql installation program, the directory location refers to the settings of this machine.
After the command is executed, a temporary password of the root user of the mysql database will be generated. Please copy it out and remember it. You need to use it to log in to mysql for the first time
.

Insert picture description here
Password: T/>%LuYxa4MS
切记粘贴复制保存

  1. Enabling the security function
    Encrypts all data transmitted back and forth between the server and the client. The authentication mechanism is provided through the certificate, and the mysql command program, mysql_ssl_rsa_setup provides the function of enabling data encryption to generate a digital certificate.
    Execute the command in the mysql-5.7.18/bin directory:

./mysql_ssl_rsa_setup --datadir=/usr/local/mysql-5.7.18/data

Insert picture description here

  1. Modify the permissions of the mysql installation directory
    After mysql is installed, you need to change the permissions of the entire folder directory of mysql-5.7.18, and change the user and group to which it belongs to the mysql user created before. At the upper level (/usr/local/) of the MySQL installation directory, execute the command chown.

E.g:

chown -R mysql:mysql /usr/local/mysql-5.7.18/

mysql:mysql represents the user and group of the folder
Insert picture description here

  1. Start MySQL to
    start the MySQL service, execute the command in the mysql-5.7.18/bin directory: ./mysqld_safe & (where the & symbol means background startup), enter the command and press Enter

The mysqld_safe program will continue to monitor its operation after starting the MySQL server, and restart it when it crashes. The practice of using the mysqld_safe program to start the MySQL server is very common on unix/linux systems.
Insert picture description here
Confirm whether msyql is started, check the process, and use ps -ef | grep mysql
Insert picture description here

  1. Use the mysql client to
    log in to mysql and enter mysql, execute the command in the mysql-5.7.18/bin directory:

./mysql -uroot -p

-u means to log in to the system as the root user and use the password generated in step 8.
-p means to log in with a password
For example: execute under mysql-5.7.18/bin./mysql -uroot -p and then Enter, enter the password at the prompt

  1. Change root password

The root user password in step 8 is temporarily modified before it can be used.
Execute the sql statement show databases; the first time you use it, you will be prompted to modify the mysql root user password:
Insert picture description here
modify the mysql password, command syntax: alter user'user name'@'host domain name or ip' identified by'new password'
For example:

alter user ‘root’@‘localhost’ identified by ‘root’;

Insert picture description here
Insert picture description here

  1. Authorize remote access
    Authorize remote access, you can only access msyql locally before you are authorized, remote authorization is to allow other computers to access mysql through the network (so that remote clients can access) authorization command: grant
    syntax:

grant all privileges on . to root@’%’ identified by ‘123456’;

Insert picture description here

Parameters:
The first of *.* represents all database names, and the second represents all database tables;
root in root@'%' represents the user name,% represents the ip address, and% can also specify a specific ip address. For example, root@localhost, [email protected]

  1. Update the permission information and execute flush to refresh the permission.
    For example:

flush privileges;

  1. Test mysql client to access mysql

Insert picture description here
Connection error: It may be that the Linux firewall is working. You can turn off the firewall first
. Commands for operating the firewall:

Check the firewall status: systemctl status firewalld to
make the firewall available: systemctl enable firewalld to
make the firewall unavailable: systemctl disable firewalld to
turn on the firewall: systemctl start firewalld to
disable the firewall: systemctl stop firewalld

Check the firewall status: execute in the linux command line.
Insert picture description here
Turn off the firewall (the local session is closed):
Insert picture description here
test the client's access:
Insert picture description here

  1. Shut down the MySQL service
    ① On the msyql client, execute exit to exit msyql's own client
    ② Close, stop the mysql server
    and execute in the mysql-5.7.18/bin directory:

./mysqladmin -uroot -p shutdown Enter the password to shut down

Check the mysql process, there is no mysqld_safe

Guess you like

Origin blog.csdn.net/qq_43518425/article/details/113774315