Teach you how to install MySQL

In daily development and learning, MySQL is indispensable. This article will teach you how to install MySQL using RPM management pack under Centos7. Let’s just start!

The MySQL version in the article is 5.7.32

Install the server

  1. Download the rpm file
    download address of the mysql server : https://downloads.mysql.com/archives/community/
    Select the version: mysql-community-server-5.7.32-1.el7.x86_64.rpm

  2. Upload to server/app/soft

  3. Install the components required by mysql
    yum install libaio(optional)

  4. If you do not install mysql Server, you will be prompted to install client dependencies and other errors
    rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --nodeps --force
    --nodeps --force

warning: mysql-community-server-5.7.32-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
 mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.32-1.el7.x86_64
 mysql-community-common(x86-64) = 5.7.32-1.el7 is needed by mysql-community-server-5.7.32-1.el7.x86_64
  1. Check whether to install

[root@review-dev soft]# rpm -qa | grep mysql
mysql-community-server-5.7.32-1.el7.x86_64
  1. Start mysql and check the status

[root@review-dev soft]# systemctl start  mysqld.service  -- 启动
[root@review-dev soft]# systemctl status mysqld.service  -- 查看状态
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-01-18 11:32:17 CST; 15s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 7054 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 6825 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 7057 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─7057 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Through the above, we have installed the server side of MySQL. At this time, it is impossible to log in with the MySQL command. You need to install a client side!

Install the client

  1. Download the rpm file
    download address of the mysql client : https://downloads.mysql.com/archives/community/
    Select the version: mysql-community-client-5.7.32-1.el7.x86_64.rpm

  2. Upload to server/app/soft

  3. The same is true for installing the client , if you do not add instructions here , the error shown below will still occur
    rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm --nodeps --force
    --nodeps --force

[root@review-dev soft]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm 
warning: mysql-community-client-5.7.32-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
 mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.32-1.el7.x86_64

After installing the Server and Client, you need to modify some default configurations.

Configuration

  1. Get original password

grep "password" /var/log/mysqld.log
2021-01-18T03:32:13.444809Z 1 [Note] A temporary password is generated for root@localhost: r8G>.aGR,GaA
  1. Use the original password to log in to the mysql server,
    mysql -uroot -penter the password obtained above and press Enter to log in

  2. Change the password where'new password' is replaced with the password you want to set. Note: The password setting must be uppercase and lowercase alphanumeric and special symbols (,/';: etc.), otherwise the configuration cannot be successful.
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'

    3.1 Change Password security policies if there are mistakes then the new password does not meet password policy through the command to view security policy
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    SHOW VARIABLES LIKE 'validate_password%';

    The corresponding security policy can be modified through commands, such as setting the password level to LOW: set global validate_password_policy=LOW;such as setting the password length to 8 set global validate_password_length=6;
mysql password policy related parameters:

1) validate_password_length the total length of the fixed password;
2) validate_password_dictionary_file specifies the file path for password verification;
3) validate_password_mixed_case_count must contain at least the total number of upper/lower case letters in the
entire password ; 4) validate_password_number_count at least in the entire password To include the number of Arabic numerals;
5) validate_password_policy specifies the strength of the password verification level, the default is MEDIUM;
6) validate_password_special_char_count the entire password must contain at least the number of special characters;

Regarding the value of validate_password_policy:
LOW: only verify length;
MEDIUM: verify length, numbers, uppercase and lowercase, special characters;
STRONG: verify length, numbers, uppercase and lowercase, special characters, dictionary files;

  1. Add remote login user

create user 'xxxxxx'@'%' identified by 'password';
GRANT ALL PRIVILEGES ON *.* TO 'xxxxxx'@'%' identified by password';
flush privileges;
  1. Modify the mysql default language to utf8mb4.
    By default, the language used by MySQL is latinl. You can use the statuscommand to view it when you log in to the mysql service . You need to modify it to the mainstream utf8mb4. First exit mysql, and then go to my in the /etc directory. The following content is added under the cnf file (see the red box)

    vi /etc/my.cnfRestart mysql after modification  
    systemctl restart mysqld.service

    Log in to mysql again and check the status again:

Through the above steps, we can already use MySQL for development and testing, but at this time MySQL cannot be directly used in production. We have to modify the configuration parameters of the MySQL server to improve its performance and throughput.

Specific parameters can refer to the following article for optimized configuration:
http://javadaily.cn/articles/2019/11/18/1574040329451.html

Above, I hope to help you!

End

Dry goods sharing

Here is a small gift for everyone, follow the official account, enter the following code, you can get the Baidu network disk address, no routines!

001: "A must-read book for programmers"
002: "Building back-end service architecture and operation and maintenance architecture for small and medium-sized Internet companies from scratch"
003: "High Concurrency Solutions for Internet Enterprises"
004: "Internet Architecture Teaching Video"
006: " SpringBoot Realization of
Ordering System" 007: "SpringSecurity actual combat video"
008: "Hadoop actual combat teaching video"
009: "Tencent 2019 Techo Developer Conference PPT"

010: WeChat exchange group

Recent hot articles top

1. Solutions for automatic renewal of JWT Token

2. SpringBoot development cheats-asynchronous event processing

3. The road of architects-server hardware literacy

4. Monitoring platform based on Prometheus and Grafana-environment setup

5. RocketMQ Advanced-Transaction Message

I knew you were "watching"

Guess you like

Origin blog.csdn.net/jianzhang11/article/details/112914528