Install mysql-5.7.28-linux-glibc2.0 in CentOS 7 12-x86_ 64.tar. gz

1 check whether mysql service is installed by default in the system. If so, uninstall it.
1) Check command

rpm -qa|grep mysql

2) Uninstall command

rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

2 if it is CentOS 7, a mysql branch database mariadb will be installed by default. You must uninstall this database first
1) Search

rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

2) Copy the found lists and uninstall them one by one, as shown in

rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64

3. Upload mysql-5.7.28-linux-glibc2 12-x86_ 64.tar. Install the GZ package in the / opt/software directory and extract it to the / opt/module directory

 tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /opt/module/

4 create directory

 mkdir /opt/module/mysql-5.7.28/data

5. Handle the permissions of the home directory and view the group and user status

cat /etc/group | grep mysql
cat /etc/passwd |grep mysql

If it exists, delete the original MySQL user: userdel -r mysql, and its corresponding group and user will be deleted
If you check, you will find no, which means you have deleted it

6. Create mysql group and mysql user

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /opt/module/mysql-5.7.28

7 create configuration files and related directories
Modify the configuration file: / etc / my CNF, if the configuration is wrong, the subsequent initialization is incomplete, and the default password will not be obtained.

vi /etc/my.cnf

Modified content:

[mysqld]
basedir=/opt/module/mysql-5.7.28
datadir=/opt/module/mysql-5.7.28/data
port = 3306
socket=/tmp/mysql.sock

symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld/mysqld.pid
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
log-bin=mysql-bin 
binlog-format=ROW 
server_id=1 
max_connections=1000

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

:wq! Save and exit.

Create the file / TMP / MySQL Sock: set user groups and users, and authorize

cd /tmp

touch mysql.sock

chown mysql:mysql mysql.sock

chmod 755 mysql.sock

Create the file / TMP / mysqld / mysqld pid:

mkdir mysqld

cd mysqld

touch mysqld.pid

cd ..

chown -R mysql:mysql mysqld

cd mysqld

chmod 755 mysqld.pid

Create the file / var.sqllog/d log:

touch /var/log/mysqld.log

chown -R mysql:mysql /var/log

cd log

chmod 755 mysqld.log

Enter the bin directory:

cd /opt/module/mysql-5.7.28/bin

Initialize database:

./mysqld --initialize --user=mysql --basedir=/opt/module/mysql-5.7.28--datadir=/opt/module/mysql-5.7.28/data

Note:

An error occurs

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

Solution:

 yum install -y libaio

If you are in an intranet environment where you can't access the Internet, you have to manually install numactl-2.0.9-2 el6. x86_ 64.rpm and libaio-0.3.109-13 el7. x86_ 64.rpm these two RPM packages

rpm -ivh  numactl-2.0.9-2.el6.x86_64.rpm

rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

Then in execution

./mysqld --initialize --user=mysql --basedir=/opt/module/mysql-5.7.28--datadir=/opt/module/mysql-5.7.28/data

Safe start:

./mysqld_safe --user=mysql &

Whether the startup is successful can be checked by checking the MySQL process, ps -ef | grep mysql

The default password is mysqld Log, find it and save it to a safe place:

cat /var/log/mysqld.log

among root@localhost : the following is the default password for login (if it cannot be found, it may be empty by default. Enter the password directly when logging in, otherwise there may be a problem with the installation)

Enter the bin directory:

cd /opt/module/mysql-5.7.28/bin

Login to mysql:

./mysql -u root -p

Copy or enter mysqld Log to enter the mysql command client.
show databases;

Suppose the password is changed to 123456

mysql> set password=password("123456");

Set remote login permissions

mysql>grant all privileges on *.* to 'root'@'%' identified by '123456'; 

Effective immediately:

mysql> flush privileges;

quit or exit;

mysql> quit;

Startup service startup settings:

Put support files / MySQL The server copy is / etc / init d/mysql:

cp -a /opt/module/mysql-5.7.28/support-files/mysql.server /etc/init.d/mysql

Check whether the mysql service is in the service configuration

chkconfig --list mysql

If not, register mysql as the service started after startup, and then view it in the

chkconfig --add mysql

chkconfig --list mysql

Start or stop

service mysql start
service mysql stop

Create shortcut:
After the service is started, run mysql -u root -p directly to log in without entering the corresponding directory.

ln -s /opt/module/mysql-5.7.28/bin/mysql /usr/bin

Tags: Linux Database MySQL

Posted by newbie5050 on Thu, 05 May 2022 10:21:04 +0300