rpm installs mysql and modifies mysql login password

Keywords: MySQL RPM yum git

Reprint https://blog.csdn.net/yejiyueshang/article/details/78745664

Linux version: CentOS 6.5 64 bit

1. Download MySQL

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
  • 1

2. decompression

mkdir mysql
cd mysql
[root@localhost mysql]# tar -xvf mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.20-1.el6.x86_64.rpm
mysql-community-common-5.7.20-1.el6.x86_64.rpm
mysql-community-client-5.7.20-1.el6.x86_64.rpm
mysql-community-test-5.7.20-1.el6.x86_64.rpm
mysql-community-server-5.7.20-1.el6.x86_64.rpm
mysql-community-devel-5.7.20-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm
mysql-community-libs-5.7.20-1.el6.x86_64.rpm
mysql-community-embedded-5.7.20-1.el6.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

3. Create MySQL user groups and users

groupadd mysql
useradd -r -g mysql mysql
  • 1
  • 2

4. Modify the current directory owner as mysql user

chown -R mysql:mysql ./
  • 1

5. Delete the original MySQL

#View installed packages
yum list installed mysql*  
#Remove all installed related software
yum remove mysql.x86_64 mysql-devel.x86_64 mysql-libs.x86_64 mysql-server.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5

6. Install MySQL in turn

rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm --nosignature
rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm --nosignature
rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm --nosignature
rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm --nosignature
  • 1
  • 2
  • 3
  • 4

Error may be reported in this step. The information is as follows:

error: Failed dependencies:
        /usr/bin/perl is needed by mysql-community-server-5.7.20-1.el6.x86_64
        libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        perl(File::Path) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        perl(Getopt::Long) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        perl(POSIX) is needed by mysql-community-server-5.7.20-1.el6.x86_64
        perl(strict) is needed by mysql-community-server-5.7.20-1.el6.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

This is a missing dependency. You can install it

yum install perl
yum install libnuma*
  • 1
  • 2

If libnuma * cannot be installed, the following message appears

[root@local mysql]# yum install libnuma*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Setting up Install Process
No package libnuma* available.
Error: Nothing to do
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

numactl can be installed instead

yum install numactl
  • 1

7. Start MySQL service

service mysqld start
  • 1

8. Set MySQL user and password

#Shut down MySQL service
service mysqld stop
#Start MySQL in safe mode
mysqld_safe --skip-grant-tables &
#Log in to MySQL, and the password is arbitrary
mysql -u root -p
#Change password
update mysql.user 
set authentication_string=password('root')
where user='root';
#Refresh authority
flush privileges;
#Quit MySQL
exit;
#Restart MySQL
service mysqld restart
#Log in to MySQL, create users and authorize
create database gogs
create user git@localhost identified by 'git';
grant all privileges on gogs.* to git@localhost;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

9. Problems encountered during installation and configuration
Problem: an error is reported when installing MySQL community server
Tips:

libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.20-1.el6.x86_64
mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.20-1.el6.x86_64
mysql-community-common(x86-64) = 5.7.20-1.el6 is needed by mysql-community-server-5.7.20-1.el6.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5

Reason:
Dependent package not installed

yum install libnuma*
  • 1

Install MySQL community community, MySQL community LIBS and MySQL community client in sequence

Question:
MySQL initialization failed
Tips:

Initialize MySQL database: [failed]
  • 1

Reason:
Original MySQL is not completely uninstalled

Question:
After logging in MySQL, no matter what is running, the same error message will be reported
Tips:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  • 1

Reason:
After changing the password in security mode, you need to modify it again in MySQL, then log out and log in again to use it normally

set password=password('Password');
alter user 'root'@'localhost' password expire never;
flush privileges;
exit;

Posted by soianyc on Thu, 02 Apr 2020 21:20:22 -0700