MySQL Installation Configuration

Posted by phpMitch on Fri, 03 Jul 2020 17:18:54 +0200

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

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

3. Create MySQL user groups and users

group mysql
useradd -r -g mysql mysql

4. Modify the current directory owner to be a mysql user

chown -R mysql:mysql ./

5. Delete 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

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

7. Start MySQL Service

service mysqld start

8. Set MySQL user and password

#Close MySQL Service
service mysqld stop
#Safe Mode Start MySQL
mysqld_safe --skip-grant-tables &
#Log on to MySQL with a random password
mysql -u root -p
#Change Password
update mysql.user 
set authentication_string=password('root')
where user='root';
#Refresh Permissions
flush privileges;
#Exit MySQL
exit;
#Restart MySQL
service mysqld restart
#Log on to MySQL, create users, and authorize
create database gogs
create user git@localhost identified by 'git';
grant all privileges on gogs.* to git@localhost;

9. Problems encountered during installation and configuration
Problem: Error 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

Reason:
Dependent packages are not installed

yum install libnuma*

Sequential installation of mysql-community-common,mysql-community-libs,mysql-community-client

Question:
MySQL initialization failed
Tips:

Initialization of MySQL database: [Failed]

Reason:
Old MySQL not completely uninstalled

Question:
Report the same error message no matter what you run after logging into MySQL
Tips:

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

Reason:
Security mode password changes require a second change in MySQL before exiting and logging in to work properly

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

Topics: MySQL RPM yum git