Get the App
SLTechnology News&Howtos  ›  Database  › 

How to install and configure Mysql in Centos7?

Shulou Source: shulou.com Published: 2022-06-01 18:38:30 10月03日 Update

There are numerous tutorials online about installing mysql databases in Linux, but most of them are riddled with holes. Today, to help those in need, write a tutorial on Centos7 installation and configuration of mysql5.7.

Step 1: get the mysql YUM source

Go to the mysql official website to get the download address of the RPM package.

Https://dev.mysql.com/downloads/repo/yum/

Right-click the copy link address https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Get the address of the rpm packet

Step 2: download and install the mysql source

Download the mysql source installation package first

[root@localhost ~] # wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

-bash: wget: command not found

Let's install wget first.

Yum-y install wget

Then execute wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Install the mysql source

Yum-y localinstall mysql57-community-release-el7-11.noarch.rpm

Step 3: install Mysql online

Yum-y install mysql-community-server

There are more things to download. You have to wait a little while.

Step 4: start the Mysql service

Systemctl start mysqld

Step 5: set boot up

Systemctl enable mysqldsystemctl daemon-reload

Step 6: change the root local login password

After the mysql installation is complete, a temporary default password is generated for root in the / var/log/mysqld.log file.

Vi / var/log/mysqld.log

The password here is: xtqh0Neteu=7

Mysql-u root-pEnter password:

Enter a temporary password to enter the mysql command line

ALTER USER 'root'@'localhost' IDENTIFIED BY' LCode1996.'

Change the password to LCode1996. (note mysql5.7 default password policy requires that the password must be a combination of uppercase and lowercase alphanumeric special letters, at least 8 digits.)

Step 7: set up to allow remote login

Mysql does not allow remote login by default. We need to set it up, and the firewall opens port 3306.

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' LCode1996.' WITH GRANT OPTION;Query OK, 0 rows affected, 1 warning (0.05 sec) mysql > exit;Bye

Quit.

[root@localhost] # firewall-cmd-- zone=public-- add-port=3306/tcp-- permanentsuccess [root@localhost ~] # firewall-cmd-- reloadsuccess [root@localhost ~] #

Open port 3306

Step 8: configure the default encoding to UTF-8

Modify the / etc/my.cnf configuration file and add the encoding configuration under [mysqld], as follows:

[mysqld] character_set_server=utf8init_connect='SET NAMES utf8' [root@localhost ~] # vi / etc/my.cnf

Restart mysql service after editing and saving: systemctl restart mysqld

Check the code below:

Mysql > show variables like'% character%'

Step 9: test

We use the local sqlyog to remotely connect the mysql in the virtual machine.

At this point, the Mysql installation and configuration is complete

Tags: Password configuration address tutorial login command letter file port code open service special numerous loopholes part thing remarks size number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology vpn Xiaomi Redmi