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 in CentOS 7 system

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

Share

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

This article shows you how to install MySQL in CentOS 7 system, the content is concise and easy to understand, absolutely can make you shine, through the detailed introduction of this article I hope you can gain something.

Download and install MySQL's official Yum Repository

On MySQl's website we can download Yum Repository.

wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

Using the above command we downloaded the Yum Repository, and then we can use yum to install it.

yum -y install mysql80-community-release-el7-1.noarch.rpm

Next we need to start installing MySQL.

yum -y install mysql-community-server

MySQL Settings

start the MySQL

systemctl start mysqld.service

View operational status

systemctl status mysqld.service

At this point, our database is up and running, but we still need to find our root password in the log to access our database. In the new version, the root password is generated by default.

grep "passsword" /var/log/mysqld.log

With the above command we can see the password of our root user.

mysql -uroot -p Enter the password to access the database.

Enter the initial password. You can't do anything at this time, because MySQL must change the password by default before you can operate the database:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

The password must have some complexity.

After changing the password, we can carry out normal operation.

However, there is still a problem at this time, that is, because Yum Repository is installed, it will be automatically updated every time yum operates in the future, so you need to uninstall this:

yum -y remove mysql80-community-release-el7-1.noarch

startup

shell> systemctl enable mysqldshell> systemctl daemon-reload

Add Remote Login User

By default, only root accounts are allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or add an account that allows remote connections. For security reasons, I add a new account:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917! ' WITH GRANT OPTION;

mysql8 is a bit different from the original version. 8 has a higher security level, so when creating a remote connection user, you can't use the original command (create user and empower at the same time):

You must create a user first (password rule: mysql8.0 or above password policy restrictions must be case plus number special symbols):

create user

mysql>create user chenadmin@'%' identified by 'Chenadmin0. ';

are value assigned

mysql>grant all privileges on *.* to chenadmin@'%' with grant option;

last refresh

mysql>flush privileges;

Configuration default encoding is utf8

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

[mysqld]character_set_server=utf8init_connect='SET NAMES utf8'

Restart mysql service

systemctl restart mysqld The above is how to install MySQL in CentOS 7. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to 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