Summary of installing mysql with rpm in centos 7, centos 7rpm

Source: Internet
Author: User
Tags yum repolist

Summary of installing mysql with rpm in centos 7, centos 7rpm

Recently, in a project, centos is used as the data server and mysql database is used to install the mysql database. I have never touched centos before, so I don't understand anything, I also checked a lot of information from the Internet and thought it was not the best method. Finally, I used the rpm method to install mysql based on official mysql Data and other user data, and summarized it for reference.

First open the mysql Pipe Network, find "yum repository" to open the page or directly open the following link

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

Find what you need and click download to download the rpm file. After downloading the file in centos, you can use the software manager or use the command line to install the house.

sudo rpm -Uvh 'filename’

Complete the installation.

Input

yum repolist all | grep mysql 

You can view all the rpm packages corresponding to mysql. If you are using a previous version, you need to set it to open

/etc/yum.repos.d/mysql-community.repo

File, set the enabled attribute of the corresponding version, 1 is enabled, 0 is disabled, if the latest version is installed, no settings are required.

Run the following command to install mysql:

sudo yum install mysql-community-server

After the installation is complete, enter the following command to start the mysql service.

sudo service mysqld start

The startup is complete. You can view the mysql service status at house.

sudo service mysqld status

If version 5.7 is installed, the following operations are performed when the service is started because the data directory is empty:

  • Initialize the server
  • Generate an SSL Certificate and key file in the Data Directory
  • Install and enable the validate_password plug-in
  • The superuser account 'root' @ 'localhost' is created, and the superuser password is set and stored in the error log file. to display it, run the following command:
sudo grep 'temporary password' /var/log/mysqld.log

A random password is generated and entered in the command line.

mysql -uroot -p 

Add the random password to log on to mysql.

After you log on to the server with this password, you must change the password immediately, otherwise the following error will be reported (local reference http://www.cnblogs.com/ivictor/p/5142809.html ):

mysql> select user();ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

If you change the password to a simple one, the following error will be reported:

mysql>  ALTER USER USER() IDENTIFIED BY '12345678';ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

  

This is actually related to the value of validate_password_policy.

Validate_password_policy has the following values:

 

Policy Tests saved med
0OrLOW Length
1OrMEDIUM Length; numeric, lowercase/uppercase, and special characters
2OrSTRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

The default value is 1, that is, MEDIUM. Therefore, the Password Must Meet the length and contain numbers, lowercase letters or uppercase letters, and special characters.

Sometimes, I only want to test the password for myself and don't want it to be so complicated. For example, I just want to set the root password to 123456.

You must modify two global parameters:

First, modify the value of the validate_password_policy parameter.

mysql> set global validate_password_policy=0;Query OK, 0 rows affected (0.00 sec)

After changing the password, you can change it to your own password.

After the configuration is complete, you need to set the remote access permission for mysql. Here there are two areas to be set: one is open to external IP addresses, and the other is open to ports.

The most common setting is to use the following command to set mysql authorization.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

To authorize an IP address, change % to your IP address.

FLUSH PRIVILEGES;

Then exit mysql and restart mysql.

service mysqld restart

Enable port 3306 through firewall-cmd in centos7

firewall-cmd --zone=public --add-port=3306/tcp --permanent

Setting complete and reload firewall

firewall-cmd --reload

Run the command to check whether port 3306 is set successfully.

firewall-cmd --list-all-zones

So far, mysql is installed and configured in centos7

 

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.