This is the 14th day of my participation in the More text Challenge. For more details, see more text Challenge

Recently, I bought a Tencent cloud server. I want to build my own blog site and prepare to use nodeJS + mySql to achieve my goal. The following is the record of installing a mySql database.

1. Installation check

Before installing, check to see if other versions of MySql and MariaDB are installed

The RPM - qa | grep mysql RPM - qa | grepm mariadb found that new servers installed by default mariadb database, RPM -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64Copy the code

2. Download the installation source

[root@VM-0-7-centos soft]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

[root@VM-0-7-centos soft]# yum -y install mysql57-community-release-el7-10.noarch.rpm

Copy the code

3. Start the installation

[root@VM-0-7-centos soft]# yum -y install mysql-community-server
Copy the code

Conclusion: Mysql is installed once both sides are finished. The second installment will take about 10 minutes, and the previous mariadb will be overwritten after this step, even if it hasn’t been uninstalled

4. Start MySql

[root@VM-0-7-centos soft]# systemctl start mysqld.service
Copy the code

5. Running status

[root@VM-0-7-centos soft]# systemctl status mysqld.service ● mysqld.service -loaded MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2021-03-29 23:42:51 CST; 34s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 11023 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 10969 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 11026 (mysqld) CGroup: / system. Slice/mysqld. Service └ ─ 11026 / usr/sbin/mysqld - daemonize - pid - file = / var/run/mysqld/mysqld. Pid 23:42:46 29 Mar VM-0-7-centos systemd[1]: Starting MySQL Server... Mar 29 23:42:51 VM-0-7-centos systemd[1]: Started MySQL Server.Copy the code

6, the original password

[root@VM-0-7-centos soft]# grep "password" /var/log/mysqld.log 2021-03-29t15:42:47.495342z 1 [Note] A temporary password  is generated for root@localhost: &NxOTa_4hQ9lCopy the code

7. Change the password

[root@VM-0-7-centos soft]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.33 Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help; ' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Your new password'; Query OK, 0 rows affected (0.04 SEC)Copy the code

8. Remote access

mysql> grant all privileges on *.* to 'root'@'%' identified by 'JamieDawn@3975' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

mysql> exit
Copy the code

If it is a specified IP address, change % to your IP address

grant all privileges on *.* to 'root'@'127.0.0.1' identified by 'JamieDawn@3975' with grant option;
Copy the code

9. Add a port

[root@VM-0-7-centos soft]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
FirewallD is not running
[root@VM-0-7-centos soft]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
FirewallD is not running
Copy the code

The firewall fails to be enabled. Check the firewall status

[root@VM-0-7-centos soft]# systemctl status firewalldLow firewalld. Service - firewalld - dynamic firewall daemon the Loaded: the Loaded (/ usr/lib/systemd/system/firewalld. Service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)Copy the code

Enable the firewall and check the firewall status again.

[root@VM-0-7-centos soft]# systemctl start firewalld
[root@VM-0-7-centos soft]# systemctl status firewalldLow firewalld. Service - firewalld - dynamic firewall daemon the Loaded: the Loaded (/ usr/lib/systemd/system/firewalld. Service; disabled; vendor preset: enabled) Active: active (running) since Mon 2021-03-29 23:59:02 CST; 15s ago Docs: man:firewalld(1) Main PID: 13435 (firewalld) CGroup: / system. Slice/firewalld service └ ─ 13435 / usr/bin/python2 - Es/usr/sbin/firewalld - nofork nopid Mar 29 23:59:02 VM-0-7-centos systemd[1]: Starting firewalld - dynamic firewall daemon... Mar 29 23:59:02 VM-0-7-centos systemd[1]: Started firewalld - dynamic firewall daemon.Copy the code

Add the Firewalld port number again

[root@VM-0-7-centos soft]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@VM-0-7-centos soft]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@VM-0-7-centos soft]# firewall-cmd --reload
success
Copy the code

10. Configure information

[root@VM-0-7-centos soft]# mysql -uroot -p
Enter password: 

mysql> status
--------------Mysql Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using EditLine Wrapper Connection ID: 3 Current database: Current user: root@localhost SSL: Not inuse
Current pager:		stdout
Using outfile:		' '
Using delimiter:	;
Server version:		5.7.33 MySQL Community Server (GPL)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/var/lib/mysql/mysql.sock
Uptime:			19 min 46 sec
Copy the code

Change the latin1 of Server Characterset to UTF8

[root@VM-0-7-centos soft]# vi /etc/my.cnf
Copy the code

Enter I to enter the edit state, and when the modification is complete

[root@VM-0-7-centos soft]# vi /etc/my.cnf [client] default-character-set=utf8 # For advice on how to change settings Both please see [mysqld] # # # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html Remove leading # and  set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock character-set-server=utf8 collation-server=utf8_general_ci # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pidCopy the code

Then: Press Esc to exit editing, then Shift + : and finally enter wq to exit and hold. If you enter q! , do not save, forced to exit, finally restart mysql

[root@VM-0-7-centos soft]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
Copy the code

Open Navicat, connect to mysql, enter password, install successfully

11,

Every installation is a harvest, record your installation experience, don’t want to be a full stack front end is not a good front end.