Testers learn Linux (6): Install mysql database on CentOS7

table of Contents

1. Master the rpm installation and uninstallation commands

2, rpm install mysql

3. Remote access to mysql

1. Master rpm installation and uninstallation commands

RPM Introduction:
RPM (Red Hat Package Manager) is an open package management system. It can be recognized as a standard for software package management in Linux on RedHat Linux and other Linux systems. The release of RPM is based on the GPL agreement. Using RPM can provide quick installation and reduce the trouble of compiling and installing.

RPM function:
rpm has the following major functions, the details are as follows:
installation: extract the software from the rpm package, and install it to the hard disk
Uninstall: uninstall the software from the system
Upgrade: replace the old version of the software;
query: query Information
of the software package ; verification: check the difference between the software in the system and the software in the package

RPM package format:
The name of the RPM package has its unique format, such as: mysql-community-server-5.7.21-1.el7.x86_64.rpm
name: mysql-community-server is the name of the software
version: 5.7.21 -1 is the software version;
type: x86_64 means compiled on 64-bit Intel x86 computer platform

Use of the rpm command:
-i: install the specified rpm file
-U: upgrade the software
-e: delete the specified software package
-q: query whether the specified software package is installed in the system
-qa: query all rpm package
-v: check the specified software package

Example:
Install the local software package: rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
Install the remote software package: rpm -ivh http://mirrors.163.com/../xxx. rpm
upgrade software package from local file: rpm -Uvh xxxx.rpm
upgrade software package from remote file: rpm -Uvh http://mirrors.163.com/../xxx.rpm
uninstall software package: rpm -e mysql
query whether Install the software package: rpm -qa | grep mysql

 

Second, rpm install mysql

In the previous section, we learned the rpm command, where we use this command to install mysql

1. First check whether mysql is already installed on the current server:

 

2. Go to mysql official website: https://dev.mysql.com/downloads/mysql/ to download the latest version of mysql rpm package, mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar


3. Since we only need to install the main services of mysql and can access mysql normally, we only need to put the
mysql-community-libs-5.7.21-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7 .21-1.el7.x86_64.rpm
mysql-community-common-5.7.21-1.el7.x86_64.rpm
mysql-community-client-5.7.21-1.el7.x86_64.rpm
mysql-community-server- 5.7.21-1.el7.x86_64.rpm
5 rpm packages are uploaded to the server, as shown in the figure

4. Start installing mysql:
4.1 Uninstall first: yum remove mariadb-libs
4.2 Install: mysql-community-common-5.7.21-1.el7.x86_64.rpm

 

 4.3 Installation: mysql-community-libs-5.7.21-1.el7.x86_64.rpm

 

Note: Because centOS comes with an old version of mariadb-libs that conflicts with the current mysql package, it needs to be uninstalled before installing

4.4 Installation: mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm

 

4.5 Installation: mysql-community-client-5.7.21-1.el7.x86_64.rpm

 4.6 Installation: perl

Execution: yum install perl
Note: It is best to use this command to install perl here. Perl depends on other 26 packages. It is very troublesome to download and install it individually
.

 4.7 Installation: mysql-community-server-5.7.21-1.el7.x86_64.rpm

 

5. Startup, configuration: After installing mysql, you need to start the mysql server to use it normally;
5.1.service mysqld restart

  5.2. First find the log file of mysql, you need to use the following command:

find: find file command
find ./ -name a.txt- find files in the current directory and subdirectories a.txt
find ./ -size + 1M-find files larger than 1M in the current directory and subdirectories

 

 5.3. To find the initial password of the root user, you need to use the following command:

grep: filter
eg cat a.txt | grep -i newdream --filter newdream lines in a.txt
grep -l mysql / sbin / * --filter the file name containing mysql under / sbin /

 

5.4. Use root and password to link to mysql, as shown below:

 6.5. Reduce the password complexity limit: set global validate_password_policy = 0;

6.6. Lower the password length limit: set global validate_password_length = 4;

6.7. Change the initial password of the root user: alter user 'root' @ 'localhost' identified by '123456';

6.8 Create a new user: create user 'root' @ '%' identified by '123456';

6.9 Authorization: GRANT ALL PRIVILEGES ON *. * TO 'root' @ '%';

6.10 Refresh privileges: flush privileges;

 

 

Three, remote access to mysql

Use the database connection tool navicat to connect to the Mysql database remotely

 

to sum up: 

 The database is the foundation of the testers, and it must be installed and used proficiently.

 

Guess you like

Origin www.cnblogs.com/xmxit-liu/p/12693131.html