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 MySQL 5.7in CentOS 7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Today, I would like to talk to you about how to install MySQL 5.7in CentOS 7. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents. I hope you can get something from this article.

The test environment for this article:

CentOS 7 64-bit Minimal MySQL 5.7

Configure yum Feed

Rpm installation package

Install the mysql source

# download shell > wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm# and install mysql source shell > yum localinstall mysql57-community-release-el7-11.noarch.rpm

Check that the mysql source is installed successfully with the following command

Shell > yum repolist enabled | grep "mysql.*-community.*"

Mysql source installed successfully

Install MySQL

Install using the yum install command

Shell > yum install mysql-community-server

Start the MySQL service

Under CentOS 7, the new command to start / shut down the service is systemctl start | stop

Shell > systemctl start mysqld

Use systemctl status to view MySQL status

Shell > systemctl status mysqld

MySQL startup status

Set up boot boot

Shell > systemctl enable mysqld shell > systemctl daemon-reload

Change the password of the root local account

After the mysql installation is complete, the default password generated is in the / var/log/mysqld.log file. Use the grep command to find the password in the log.

Shell > grep 'temporary password' / var/log/mysqld.log

View temporary password

After logging in with the initial password for the first time, use the following command to change the password

Shell > mysql-uroot-p mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' MyNewPass4passport'

Or

Mysql > set password for 'root'@'localhost'=password (' MyNewPass4passport')

Change the password later through the update set statement

Mysql > use mysql; mysql > update user set password=PASSWORD ('MyNewPass5passport') Where user='root'

Note: the password Security check plug-in (validate_password) is installed by default in mysql 5.7. the default password checking policy requires that passwords must contain uppercase and lowercase letters, numbers, and special symbols, and must be no less than 8 digits in length. Otherwise, ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error will be prompted. View the detailed password policy of the MySQL official website

Add a Telnet user

By default, only root accounts are allowed to log in locally, and if you want to connect to mysql on other machines, you must add an account that allows remote connections. Or modify root to allow remote connections (not recommended)

Add an account that allows remote connections

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'zhangsan'@'%' IDENTIFIED BY' Zhangsan2018 WITH GRANT OPTION

Modify root to allow remote connections (not recommended)

Mysql > use mysql; mysql > UPDATE user SET Host='%' WHERE User='root'; mysql > flush privileges

Set the default encoding to utf8

Mysql does not support Chinese by default after installation, and the encoding needs to be modified.

Modify the / etc/my.cnf configuration file and add the encoding configuration under the relevant nodes (if not), as follows:

The copy code is as follows:

[mysqld]

Character-set-server=utf8

[client]

Default-character-set=utf8

[mysql]

Default-character-set=utf8

Restart the mysql service and query the code. You can see that it has been changed.

Shell > systemctl restart mysqld shell > mysql-uroot-p mysql > show variables like 'character%'

View the encoding default profile path:

Configuration file: / etc/my.cnf

Log file: / var/log/var/log/mysqld.log

Service startup script: / usr/lib/systemd/system/mysqld.service

Socket file: / var/run/mysqld/mysqld.pid

After reading the above, do you have any further understanding of how to install MySQL 5.7 in CentOS 7? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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