Installing MySQL5.7 with Yum under CentOS

Source: Internet
Author: User

1. Go to the location where you want to store the installation package

Cd/home/lnmp

2. To see if the MySQL service is installed on the system, here are two ways:

rpm-qa | grep mysql Yum List installed | grep mysql

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

Yum -y remove mysql-libs.x86_64

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

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, the following two packages are available:

Mysql-community.repo
Mysql-community-source.repo

6. Install MySQL, if prompted, all the way Y

Yum Install Mysql-server

After installation, a random password is automatically generated in the/var/log/mysqld.log file and we need to obtain this random password to log on to the MySQL server:

grep " Password " /var/log/mysqld.log

The following will be returned, with the string at the end being the password and copying it:

 for [Email protected]: hilx0u!9i3_6

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

Note: Since MySQL5.7 uses the password strength verification plugin Validate_password, we need to set a password with a certain strength;

Mysql-u Root-philx0u!9i3_6

Setting the user root can be accessed under any IP:

Grant all privileges on * * to root@ "%"" new password ";

Setting the user root can be accessed locally:

Grant all privileges on * * to root@ "localhost"" new password ";

Refresh permissions to make it effective:

Flush privileges;

Update the password for the user root of MySQL:

Set password = password (' new password ' )

Enter exit and log in again with your new password!

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

Service mysqld startservice mysqld stopservice mysqld restartservice mysqld Status

9. View the MySQL character set:

 like ' %character% ';

+-----------------------------------+---------------------------------------+

| variable_name | Value |
+-----------------------------------+---------------------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | Latin1 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+------------------------------------+---------------------------------------+
8 rows in Set (0.01 sec)


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

Table  from  like ' %servers% ';

11. View the character set for all columns of the specified table in the specified database, such as the character set for viewing all columns of the servers table in the MySQL database:

 Full  from servers;

12. Set the MySQL charset to UTF-8:
Open the My.cnf file in the/etc directory (this file is the main configuration file for MySQL):

Cd/etc/my.cnf

Add the following code before [mysqld]:

[Client]default-character-set=utf8

Add the following code after [mysqld]:

Character_set_server=utf8

To view the character set again:

 like ' %character% ';

+-----------------------------------+---------------------------------------+

| variable_name | Value |
+-----------------------------------+---------------------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+------------------------------------+---------------------------------------+
8 rows in Set (0.01 sec)

13. Directory where database files are stored

Cd/var/lib/mysql

MySQL Log Record file

Vim/var/log/mysqld.log

MySQL uses the TCP/IP protocol to transmit data, the default port number is 3306, we can see by the following command:

Netstat-anp

16. When you forget your password, you can reset it as follows:

--user=root--skip-grant-tables--skip-networking &-u root

After entering MySQL

 Use MySQL; Update User set Password=whereuser=privileges;

This article is organized from:

Https://www.linuxidc.com/Linux/2016-06/132676.htm

Installing MySQL5.7 with Yum under CentOS

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.