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 using YUM in CentOS7 system

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you how to use YUM to install MySQL5.7 in the CentOS7 system, 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. Go to the location where you want to store the installation package

Cd / home/lnmp

two。 There are two ways to check to see if the MySQL service is installed on the system:

Rpm-qa | grep mysqlyum list installed | grep mysql

3. If installed, remove MySQL and its dependent packages:

Yum-y remove mysql-libs.x86_64

4. Download the YUM source for mysql57-community-release-el7-8.noarch.rpm:

Wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

5. Install mysql57-community-release-el7-8.noarch.rpm:

Rpm-ivh mysql57-community-release-el7-8.noarch.rpm

After installation, you get the following two packages:

Mysql-community.repomysql-community-source.repo

6. If prompted to install MySQL, go all the way to the end.

Yum install mysql-server

After installation, run mysql, and then a random password is automatically generated in the / var/log/mysqld.log file. We need to get this random password first to log in to the MySQL server:

Service mysqld startgrep "password" / var/log/mysqld.log

The following will be returned, and the end string is the password. Copy it down:

A temporary password is generated for root@localhost: hilX0U!9i3_6

7. Log in to the MySQL server and update the password of user root:

Note: since MySQL5.7 uses the password strength verification plug-in validate_password, we need to set a password with a certain strength.

Mysql-u root-Phillips X0 Utility 9i3mm 6

Then change the password

SET PASSWORD = PASSWORD ('your new password'); ALTER USER' root'@'localhost' PASSWORD EXPIRE NEVER;flush privileges

Set the user root to be accessed under any IP:

Grant all privileges on *. * to root@ "%" identified by "new password"

Set the user root to be accessed locally:

Grant all privileges on *. * to root@ "localhost" identified by "new password"

Refresh permissions to take effect:

Flush privileges

OK, enter exit and log in again with your new password.

Note: if you still can't connect with the remote tool, try the iptables-F command to clear the rules in the chain in the firewall

8.MySQL control commands: start, stop, restart, view status

Service mysqld startservice mysqld stopservice mysqld restartservice mysqld statussystemctl start mysqldservice mysqld stopservice mysqld restartsystemctl status mysqld

9. Set the character set of MySQL to UTF-8:

Open the my.cnf file in the / etc directory (this file is the main configuration file for MySQL):

Vim / etc/my.cnf

Add the following code before [mysqld]:

[client] default-character-set=utf8

Add the following code after [mysqld]:

Character_set_server=utf8

Log in to mysql again and look at the character set. Six utf8 is considered OK.

Show variables like'% character%'

10. View the character set of the specified data table in the specified database, such as the character set of the servers table in the mysql database:

Show table status from mysql like'% servers%'

View the character set of all columns of the specified table in the specified database, such as the character set of all columns of the servers table in the mysql database:

Show full columns from servers

11. When you forget your password, you can reset it in the following ways:

Service mysqld stopmysqld_safe-user=root-skip-grant-tables-skip-networking & mysql-u root

After entering MySQL

Use mysql;update user set password=password ("new_password") where user= "root"; flush privileges

twelve。 The directory where some files are stored.

Configuration file

Vim / etc/my.cnf

The directory where the database files are stored

Cd / var/lib/mysql

Logging file

Vim / var/log/ mysqld.log

Service startup script

/ usr/lib/systemd/system/mysqld.service

Socket file

/ var/run/mysqld/mysqld.pid

13.MySQL uses TCP/IP protocol to transfer data. The default port number is 3306, which can be viewed by the following command:

Netstat-anp

The above content is how to use YUM to install MySQL5.7 in CentOS7 system. Have you learned the 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

Database

Wechat

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

12
Report