Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install mysql5.7 in centos

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to install mysql5.7 in centos. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. View the current centos system

[root@43-c58481263-0048-1225006 /] # cat / etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@43-c58481263-0048-1225006 /] # uname-a

Linux 43-c58481263-0048-1225006.novalocal 3.10.0-327.el7.x86_64 # 1 SMP Thu Nov 19 22:10:57 UTC 2015 x86 "64 GNU/Linux

[root@43-c58481263-0048-1225006 /] #

two。 View the database MariaDB installed by default in centos7

[root@43-c58481263-0048-1225006 /] # rpm-qa | grep mariadb

Mariadb-libs-5.5.56-2.el7.x86_64

[root@43-c58481263-0048-1225006 /] #

3. Uninstall the default database for the centos installation

[root@43-c58481263-0048-1225006 /] # rpm-qa | grep mariadb

Mariadb-libs-5.5.56-2.el7.x86_64

[root@43-c58481263-0048-1225006 /] # rpm-e-nodeps mariadb-libs-5.5.56-2.el7.x86_64

[root@43-c58481263-0048-1225006 /] # rpm-qa | grep mariadb

[root@43-c58481263-0048-1225006 /] #

4. Download mysql

Go to the official website to find mysql download address: https://dev.mysql.com/downloads/repo/yum/

Corresponding centos version:

Execute the following command to download mysql

[root@43-c58481263-0048-1225006 java] # wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

-- 2019-07-24 14-14-14-14-14-14-14-7-14-14-14-14-14-14-14-7-24-14-14-14-14-14-14-14-- 14-14-14-14-14-- 14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14

Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11

Connecting to dev.mysql.com (dev.mysql.com) | 137.254.60.11 |: 443. Connected.

HTTP request sent, awaiting response... 302 Found

Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]

-- 2019-07-24 14-14-14-14-14-14-14-14-7-14-14-14-14-14-14-14-14-14-14-14-- 14-14-14-14-14-14-14-14-14-- 14-14-14-14-14-14-- 14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-14-

Resolving repo.mysql.com (repo.mysql.com)... 96.16.173.94

Connecting to repo.mysql.com (repo.mysql.com) | 96.16.173.94 |: 443. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 26024 (25K) [application/x-redhat-package-manager]

Saving to: 'mysql80-community-release-el7-3.noarch.rpm'

100% [= >] 26024-K in s 0.05s

2019-07-24 14:14:50 (515 KB/s)-'mysql80-community-release-el7-3.noarch.rpm' saved [26024and26024]

[root@43-c58481263-0048-1225006 java] # ll

Total 190744

-rw-r--r-- 1 root root 195094741 Jul 23 17:50 jdk-8u221-linux-x64.tar.gz

-rw-r--r-- 1 root root 26024 Apr 25 02:29 mysql80-community-release-el7-3.noarch.rpm

The screenshot above shows that the download is successful, and then install it.

[root@43-c58481263-0048-1225006 java] # rpm-ivh mysql80-community-release-el7-3.noarch.rpm

Warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... # # [100%]

Updating / installing...

1:mysql80-community-release-el7-3 # #

[root@43-c58481263-0048-1225006 java] #

Next, take a look at the mysql installation package in the Yum source

[root@43-c58481263-0048-1225006 java] # yum repolist all | grep mysql

Mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled

Mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community-disabled

Mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled

Mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community-disabled

Mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community disabled

Mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community-disabled

Mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 118

Mysql-connectors-community-source MySQL Connectors Community-disabled

Mysql-tools-community/x86_64 MySQL Tools Community enabled: 95

Mysql-tools-community-source MySQL Tools Community-Sourc disabled

Mysql-tools-preview/x86_64 MySQL Tools Preview disabled

Mysql-tools-preview-source MySQL Tools Preview-Source disabled

Mysql55-community/x86_64 MySQL 5.5 Community Server disabled

Mysql55-community-source MySQL 5.5 Community Server-disabled

Mysql56-community/x86_64 MySQL 5.6 Community Server disabled

Mysql56-community-source MySQL 5.6Community Server-disabled

Mysql57-community/x86_64 MySQL 5.7 Community Server disabled

Mysql57-community-source MySQL 5.7Community Server-disabled

Mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 129

Mysql80-community-source MySQL 8.0 Community Server-disabled

[root@43-c58481263-0048-1225006 java] #

As you can see in the figure above, the default version of the installation package enabled in the yum source is Mysql8.0. If you need to switch to 5.7, you need to execute the following command

[root@43-c58481263-0048-1225006 java] # sudo yum-config-manager-disable mysql80-community

[root@43-c58481263-0048-1225006 java] # sudo yum-config-manager-enable mysql57-community

For example, the above two commands disable mysql8 and enable mysql5.7, and then we query whether the above command was executed successfully.

[root@43-c58481263-0048-1225006 java] # yum repolist all | grep mysql

Mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled

Mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community-disabled

Mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled

Mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community-disabled

Mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community disabled

Mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community-disabled

Mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 118

Mysql-connectors-community-source MySQL Connectors Community-disabled

Mysql-tools-community/x86_64 MySQL Tools Community enabled: 95

Mysql-tools-community-source MySQL Tools Community-Sourc disabled

Mysql-tools-preview/x86_64 MySQL Tools Preview disabled

Mysql-tools-preview-source MySQL Tools Preview-Source disabled

Mysql55-community/x86_64 MySQL 5.5 Community Server disabled

Mysql55-community-source MySQL 5.5 Community Server-disabled

Mysql56-community/x86_64 MySQL 5.6 Community Server disabled

Mysql56-community-source MySQL 5.6Community Server-disabled

Mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 364

Mysql57-community-source MySQL 5.7Community Server-disabled

Mysql80-community/x86_64 MySQL 8.0 Community Server disabled

Mysql80-community-source MySQL 8.0 Community Server-disabled

As you can see from above, mysql80-community is disabled and mysql57-community is enabled.

5. Install mysql

Execute the following installation command. If you encounter a dependency, select y.

[root@43-c58481263-0048-1225006 java] # yum install mysql-community-server Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile

Base: 100.125.0.40

Extras: 100.125.0.40

Updates: 100.125.0.40 Resolving Dependencies-- > Running transaction check-- > Package mysql-community-server.x86_64 0updates 5.7.27-1.el7 will be installed-- > Processing Dependency: mysql-community-common (x86-64) = 5.7.27-1.el7 for package: mysql-community-server-5.7.27-1.el7.x86_64-- > Processing Dependency: mysql-community-client (x86-64) > = 5.7.9 for package: mysql- Community-server-5.7.27-1.el7.x86_64-- > Running transaction check-> Package mysql-community-client.x86_64 0Running transaction check 5.7.27-1.el7 will be installed-> Processing Dependency: mysql-community-libs (x86-64) > = 5.7.9 for package: mysql-community-client-5.7.27-1.el7.x86_64-- > Package mysql-community-common.x86_64 0Rule 5.7.27-1.el7 Will be installed-- > Running transaction check-> Package mysql-community-libs.x86_64 0pur5.7.27-1.el7 will be installed-- > Finished Dependency Resolution

Dependencies Resolved. Installed: mysql-community-server.x86_64 0rig 5.7.27-1.el7 Dependency Installed: mysql-community-client.x86_64 0v 5.7.27-1.el7 mysql-community-common.x86_64 0v 5.7.27-1.el7 mysql-community-libs.x86_64 0v 5.7.27-1.el7

Complete!

[root@43-c58481263-0048-1225006 java] #

6. Start mysql to check the running status of mysql

[root@43-c58481263-0048-1225006 java] # systemctl start mysqld.service

[root@43-c58481263-0048-1225006 java] # systemctl status mysqld.service

● mysqld.service-MySQL Server

Loaded: loaded (/ usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since Wed 2019-07-24 16:14:18 CST; 26s ago

Docs: man:mysqld (8)

Http://dev.mysql.com/doc/refman/en/using-systemd.html

Process: 23775 ExecStart=/usr/sbin/mysqld-daemonize-pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)

Process: 23697 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Main PID: 23778 (mysqld)

CGroup: / system.slice/mysqld.service

└─ 23778 / usr/sbin/mysqld-daemonize-pid-file=/var/run/mysqld/mysqld.pid

Jul 24 16:14:11 43-c58481263-0048-1225006.novalocal systemd [1]: Starting MySQL Server...

Jul 24 16:14:18 43-c58481263-0048-1225006.novalocal systemd [1]: Started MySQL Server.

[root@43-c58481263-0048-1225006 java] #

Check out Active: active (running) and Started MySQL Server. You can know that mysql Server is started.

7. Log in to mysql

For the first time, you need to set mysql secret-free login.

[root@43-c58481263-0048-1225006 /] # vi / etc/my.cnf

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

Symbolic-links=0

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

Skip-grant-tables

-- INSERT--

That is, insert the line skip-grant-tables at the end to set secret-free login.

After modifying the configuration file, you need to restart mysql

[root@43-c59438365-0048-0727982 mysql] # systemctl restart mysqld.service

[root@43-c59438365-0048-0727982 mysql] # systemctl status mysqld.service

Then enter mysql and execute the following command

[root@43-c58481263-0048-1225006 /] # mysql-u root

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 8

Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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 >

The next step is to update mysql password

Mysql > update mysql.user set authentication_string=password ('123456') where user='root'

Refresh permissions

Mysql > flush privileges

And then quit.

Quit

Then update the my.cnf file, remove the line of secret-free login, and save and restart mysql

Mysql > vi / etc/my.cnf

Mysql > systemctl restart mysqld

Then you can log in with the new password.

8. Set public network access

Mysql > grant all on. To root@'%' identified by '123456'

Query OK, 0 rows affected, 1 warning (0.00 sec)

Mysql >

The above is how to install mysql5.7 in centos. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report