• notice
  • Congratulations on the launch of the Sought Tech site

MySQL installation under linux

(1) Check whether MySql has been installed in the current system

[angusmyz@mysql ~]$ rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[angusmyz@mysql ~]$ sudo yum -y remove mariadb-libs

(2) Copy the mysql installation package to the Linux software package directory##

[angusmyz@mysql software]$ ll
Total amount 531112
-rw-rw-r-- 1 angusmyz angusmyz 543856640 June 15 09:14 mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar

(3) Unzip the MySql installation package

[angusmyz@mysql software]$ tar xvf mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-5.7.34-1.el7.x86_64.rpm
mysql-community-common-5.7.34-1.el7.x86_64.rpm
mysql-community-devel-5.7.34-1.el7.x86_64.rpm
mysql-community-embedded-5.7.34-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.34-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.34-1.el7.x86_64.rpm
mysql-community-libs-5.7.34-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
mysql-community-server-5.7.34-1.el7.x86_64.rpm
mysql-community-test-5.7.34-1.el7.x86_64.rpm
[angusmyz@mysql software]$ ll
Total amount 1062228
-rw-rw-r-- 1 angusmyz angusmyz 543856640 June 15 09:14 mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 angusmyz angusmyz 26597364 March 27 00:49 mysql-community-client-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 317444 March 27 00:49 mysql-community-common-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 4119104 March 27 00:49 mysql-community-devel-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 47479092 March 27 00:49 mysql-community-embedded-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 23264364 March 27 00:49 mysql-community-embedded-compat-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 131605536 March 27 00:49 mysql-community-embedded-devel-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 2472844 March 27 00:49 mysql-community-libs-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 1262704 March 27 00:49 mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 181833876 March 27 00:50 mysql-community-server-5.7.34-1.el7.x86_64.rpm
-rw-r--r-- 1 angusmyz angusmyz 124888148 March 27 00:50 mysql-community-test-5.7.34-1.el7.x86_64.rpm

(4) Perform rpm installation in the installation directory

[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-common-5.7.34-1.el7.x86_64.rpm
[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-libs-5.7.34-1.el7.x86_64.rpm
[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm
[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm
Warning: mysql-community-server-5.7.34-1.el7.x86_64.rpm: header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Error: Dependency check failed:
         net-tools is required by mysql-community-server-5.7.34-1.el7.x86_64
[angusmyz@mysql software]$ sudo yum -y install net-tools
[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm

Note: execute in order

If Linux is installed minimally, the following error may occur when installing mysql-community-server-5.7.34-1.el7.x86_64.rpm

[angusmyz@mysql software]$ sudo rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm

Warning: mysql-community-server-5.7.34-1.el7.x86_64.rpm: header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Error: Dependency check failed:

libaio.so.1()(64bit) is required by mysql-community-server-5.7.34-1.el7.x86_64

libaio.so.1(LIBAIO_0.1)(64bit) is required by mysql-community-server-5.7.34-1.el7.x86_64

libaio.so.1(LIBAIO_0.4)(64bit) is required by mysql-community-server-5.7.34-1.el7.x86_64

Install the missing dependencies through yum, and then reinstall mysql-community-server-5.7.34-1.el7.x86_64

[angusmyz@mysql software] yum install -y libaio

(5) Delete all the contents of the directory pointed to by datadir in the /etc/my.cnf folder, if there is any content, the situation is as follows:

View the value of datadir:

[mysqld]
datadir=/var/lib/mysql

Delete all the contents in the /var/lib/mysql directory:

[angusmyz@mysql mysql]# cd /var/lib/mysql
[angusmyz@mysql mysql]# sudo rm -rf ./*

(6) Initialize the database

[angusmyz@mysql ~]$ sudo mysqld --initialize --user=mysql

(7) View the generated root user password

[angusmyz@mysql ~]$ sudo cat /var/log/mysqld.log
2021-06-15T01:50:51.591750Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-15T01:50:53.660213Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-06-15T01:50:54.000395Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-06-15T01:50:54.123893Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1ecbb407-cd7c-11eb-bfed- 000c2932fba3.
2021-06-15T01:50:54.124628Z 0 [Warning] Gtid table is not ready to be used. Table'mysql.gtid_executed' cannot be opened.
2021-06-15T01:50:54.680636Z 0 [Warning] CA certificate ca.pem is self signed.
2021-06-15T01:50:54.947242Z 1 [Note] A temporary password is generated for root@localhost: ,Jf0Z8N<5aRL

(8) Start MySQL service

[angusmyz@mysql ~]$ sudo systemctl start mysqld

(9) Log in to the MySQL database

[angusmyz@mysql ~]$ mysql -uroot -p
Enter password: Enter the temporarily generated password
   login successful.

(10) The password of the root user must be changed first, otherwise an error will be reported when performing other operations

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

(11) Modify the root user in the user table under the mysql library to allow any IP link

mysql> update mysql.user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

(12) Modify the /etc/my.cnf file and add the following content

collation_server = utf8_general_ci
character_set_server = utf8
lower_case_table_names = 1
max_allowed_packet=1024M
[client]
default_character_set=utf8

(13) View database code

mysql> show variables like'character%';
+--------------------------+---------------------- ------+
| Variable_name | Value |
+--------------------------+---------------------- ------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ | |
+--------------------------+---------------------- ------+
8 rows in set (0.01 sec)


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+