Centos7 installs mysql5.7.4 (rpm installation version) and MySQL5.7.4glibc version Linux installation

1. Download the rpm installation package of mysql5.7

The mysql package of rpm is easy to install. The decompressed version of mysql requires a lot of configuration, and errors may occur if you are not careful! ! !
Download address: linkhttps://downloads.mysql.com/archives/community/

Select version
Insert image description here
The downloaded installation package looks like this
Insert image description here

2. Upload the mysql installation package to the centos7 system

xshell is used here to connect and upload to centos7

  首先安装lrzsz,这样就可以在xshell中拖拽上传了(非必须,只是方便拖拽上传)
[root@localhost src]# yum install lrzsz

I am using finalshell. There is no need to install that thing. Just drag it directly to this area.
Insert image description here

3. Install dependencies

3.1 Check whether mysql has been installed on Linux, and uninstall it if so.

Generally centos7 has mariadb installed by default, so uninstall it here.
View: rpm -qa|grep mariadb

rpm -qa|grep mariadb

Uninstall: rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64 This is what you searched for, change it to your own, otherwise an error will be reported below.

卸载:rpm -e --nodeps xxx

If you are worried about problems: add –nodeps and the system will be forced to uninstall
rpm -e --nodeps mariadb-libs

rpm -e --nodeps xxx

3.2 Install dependencies required for mysql5.7

yum install libaio  perl  net-tools

When installing dependencies, you will be asked whether to download and install, download or not download. (Enter y and press Enter to download and install.)
I didn't encounter pressing y, it just happened.
Insert image description here

4. Install mysql5.7

4.1 Unzip the mysql5.7 installation package

tar -xvf mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar

After decompression, there will be many rpm files, these are what we need to install.
Insert image description here

4.2 Install mysql5.7

rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm
 rpm -ivh mysql-community-libs-5.7.24-1.el7.x86_64.rpm
 rpm -ivh mysql-community-client-5.7.24-1.el7.x86_64.rpm
 rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm

When installing mysql using tar package:

error while loading shared libraries: libaio.so.1 : cannot open shared object file: No such file or directory

error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

libaio.so.1, libnuma.so.1 is missing or the version does not correspond.

Direct installation: yum -y install numactl problem solving
If error occurs: Dependency detection failed: mysql-community-libs(x86-64) >= 5.7.9 is required by mysql-community-client-5.7.16-1.el7.x86_64:

Insert image description here
Not uninstalled cleanly!
Insert image description here

4.3 Check the status of mysql5.7. If it is not started, start mysql.

View mysql startup status

service mysqld status

Starting mysql active(running) means the startup is successful

service mysqld start

4.4 Change password

View the temporary password: The temporary password is as shown in the figure

 grep password /var/log/mysqld.log

Insert image description here

Log in to mysql with a temporary password
mysql -uroot –p
Change to a new password
mysql> set password = password(“Szfore_68638”);

mysql password change error: Your password does not satisfy the current policy requirements

This is when mysql is initialized, a temporary password is used. When changing the custom password, because the custom password is relatively simple, there is a problem that does not comply with the password policy.
Password policy problem exception message:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Solution
1. View the initial password policy of mysql,
Enter the statement " SHOW VARIABLES LIKE 'validate_password%'; " to view,
2. First, you need to set the verification strength level of the password. Set the global parameter of validate_password_policy to LOW.
Enter the setting statement "set global validate_password_policy=LOW;" to set the value. 6), validate_password_special_char_count The entire password must contain at least the number of special characters Number; 2/STRONG: Verify length, numbers, case, special characters, dictionary files; 1/MEDIUM: verify the length, numbers, case, and special characters; 0/LOW: only verify the length; About the value of validate_password_policy: 5), validate_password_policy specifies the strength verification level of the password, the default is MEDIUM; 1), validate_password_length fixed the total length of the password; 3). validate_password_mixed_case_count The entire password must contain at least the total number of upper/lowercase letters; 2). validate_password_dictionary_file specifies the file path for password verification; About mysql password policy related parameters; As long as the password is set If the length is less than 3, the value will be automatically set to 4. Note: The minimum length of the default password is 4, consisting of one uppercase/lowercase letter + one Arabic numeral + one special character. Enter the modification statement "ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';" You can see that the modification is successful, indicating that the password policy has been modified successfully! ! ! 4. Now you can set a simple password for mysql, as long as it meets the six-digit length. Enter the setting statement " set global validate_password_length=6; " to set the value,
3. The current password length is 8. If you don’t mind, you don’t need to change it. Generally speaking, set it to a 6-digit password and set the global parameter of validate_password_length to 6.















4.5 Open remote connection and allow remote connection to the database

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Szfore_68638' WITH GRANT OPTION;

4.6 Configure the mysql configuration file my.cnf (you can also use the default one, I personally think it is better to configure it)

Open the configuration file my.cnf
vi /etc/my.cnf
Configure a few lines under [mysqld]
lower_case_table_names=1 #Configure table names to be case-insensitive 1: case-insensitive 0: case-sensitive This line must be configured. The default table name is case-sensitive, which is not conducive to development
character-set-server=utf8 #Set the default encoding to utf8
init_connect='SET NAMES utf8'
max_connections=1024 #Set the maximum number of connections service mysqld restart
Restart mysql to restart the configuration to take effect

4.7 Firewall open port

In fact, mysql has been installed and configured at this point, but the firewall is turned on in centos7, and mysql is still not accessible from the outside, so port 3306 needs to be opened (or the firewall can be turned off, not used in production environments)

Turn off firewall

systemctl stop firewalld

At this point, the installation of mysql5.7 under centos7 is completed.

Note: Centos7’s firewall has become firewalld, and the previous version of Centos7 was iptables.

MySQL5.7glibc version Linux installation

1 Download the installation package:

    清华大学开源软件镜像站:

https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
mysql official post:
https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
2 上传到linux

    linux安装上传工具:yum install lrzsz

    到linux根目录:

            cd /

    新建文件夹,用来存放上传文件

            mkdir /soft

    上传安装包:

            拖到  /soft目录

    新建文件夹,用来存放mysql相关文件

            mkdir -p data/mysql_data

3 Install mysql

    3.1 解压
            tar -zxf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
    3.2 移动
            mv /soft/mysql-5.7.34-linux-glibc2.12-x86_64 /usr/local/mysql

    3.3 创建账号

            useradd -r -s /sbin/nologin mysql

     3.4 设置目录/usr/local/mysql 拥有者与所属组均为mysql

            chown -R mysql.mysql /data/mysql

    3.5 初始化数据库

            /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure  --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data/

    3.6 移动support-files 目录下的mysql.server脚本到 /etc/init.d 目录一份

            cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

    3.7 增加 mysqld 服务控制脚本执行权限:

            chmod +x /etc/rc.d/init.d/mysqld

    3.8 将mysqld 服务加入到系统服务

            chkconfig --add mysqld

    3.9 检查mysqld服务是否已经生效

            chkconfig --list mysqld

    3.10 查看启动项

            chkconfig --list | grep -i mysql

    3.11 设置mysql开机自启

            chkconfig mysql on

    3.12 检查开机是否自启

            netsysv

    3.13 启动mysql服务

            service mysqld start

4 Configure environment variables

    4.1 配置文件

            打开文件:vim /etc/profile

            修改内容:

                    PATH=$PATH:/usr/local/mysql/bin

                    export PATH

    4.2 使修改生效

            source /etc/profile

    4.3 查看PATH值:

            echo $PATH

5 Log in to MySQL

    mysql -uroot -p

    密码:空

6 Change root password

    /usr/local/mysql/bin/mysqladmin -u root password 'root';

7 Log in to MySQL again

    mysql -uroot -p

    密码:root

Thanks for the article: https://blog.csdn.net/weixin_45623111/article/details/118295821

https://blog.csdn.net/u013449046/article/details/106455041/

Guess you like

Origin blog.csdn.net/csl12919/article/details/129690107