Detailed installation tutorial of mysql 5.7 under CentOS 6 and 7

Detailed installation tutorial of mysql 5.7 under CentOS 6 and 7

You always need data for development. As a server, Linux always needs a database to store test data. So, here is a tutorial on how to install MySQL 5.7 on CentOS 6 and 7.

Tools used: CentOs6, 7; Mysql dependency package

Step 1. Check the installed mysql:

# yum list installed | grep mysql
mysql-libs.x86_64 5.1.71-1.el6 @anaconda-CentOS-201311272149.x86_64/6.5

Uninstall the current mysql:

# yum -y remove mysql-libs.x86_64

Step 2. Download and install the required dependencies:

First go here to download, and choose according to your Linux version. For example, I am using Centos6.5, so I choose the second one, and so on:

Upload the downloaded mysql80-community-release-el6-1.noarch.rpm file to the Linux server

Step 3. Install dependencies:

Use the following command. Note that this command needs to be executed in the directory where the mysql80-community-release-el6-1.noarch.rpm file is located.

During the execution, Is this ok [y/N]: will appear. Just enter y.

# yum localinstall mysql80-community-release-el6-1.noarch.rpm

After execution, use the command # ls /etc/yum.repos.d to see that two more files have been added

# ls /etc/yum.repos.d
mysql-community.repo mysql-community-source.repo

Step 4. Run yum repolist enabled | grep mysql to check whether mysql57 is available.

If the result of running is as follows:

# yum repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community 59
mysql-tools-community MySQL Tools Community 65
mysql80-community MySQL 8.0 Community Server 29

You need to use the command vim /etc/yum.repos.d/mysql-community.repo to modify the enabled of mysql57 to 1, and set other versions to 0. The details are as follows:

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

Modified part:

......
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 ......
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

The result of the operation after setting is:

# yum repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community 59
mysql-tools-community MySQL Tools Community 65
mysql57-community MySQL 5.7 Community Server 273

Step 5. Start installation:

# yum install mysql-community-server

If an error occurs during the process, it is usually due to network speed issues. You can repeat this command.

Step 6. After the installation is complete, start the MySQL service (it may fail the first time, so run it again~):

# service mysqld start
Initializing MySQL database: [FAILED]
# service mysqld start
Starting mysqld: [ OK ]

Step 7. View the default root user's password:

# cat /var/log/mysqld.log | grep root@localhost
2018-08-29T03:11:26.560863Z 1 [Note] A temporary password is generated for root@localhost: DJ#erA*-p6&?

DJ#erA*-p6&? is the initial password of the root user

Step 8. Use the mysql -uroot -p command to log in. You need to enter the password in the previous step.

After entering, any operation will prompt ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. At this time, you need to reset the password:

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=password('new_password');
Query OK, 0 rows affected, 1 warning (0.01 sec)
 
mysql> alter user 'root'@'localhost' password expire never;
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Then exit mysql and log in again using the new password.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Installation of mysql-community-server. 5.7.18-1.el6 under centos 6.5
  • Detailed tutorial on installing MySQL 5.7.6+ from source in CentOS 7
  • Deploy MySQL 5.7.17 binary installation and multi-instance configuration on CentOS 6.5
  • Detailed tutorial on installing MySQL 5.7.20 on RedHat 6.5/CentOS 6.5
  • Detailed tutorial on installing MySQL 5.7.18 under CentOS 6.5
  • Centos6.5 compile and install mysql 5.7.14 detailed tutorial
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • Detailed instructions for compiling and installing CentOS MySQL 5.7
  • Installation tutorial of mysql 5.7 under CentOS 7
  • MySQL 5.7.17 installation and configuration tutorial under CentOS6.9

<<:  How to implement the jQuery carousel function

>>:  How to configure Nginx domain name rewriting and wildcard domain name resolution

Recommend

How to check if the firewall is turned off in Linux

1. Service method Check the firewall status: [roo...

MySQL series 6 users and authorization

Table of contents Tutorial Series 1. User Managem...

Six tips to increase web page loading speed

Secondly, the ranking of keywords is also related ...

Implementing a simple timer based on Vue method

Vue's simple timer is for your reference. The...

Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx

I. Introduction Docker technology is very popular...

Summarize the User-Agent of popular browsers

1. Basic knowledge: Http Header User-Agent User A...

The use of FrameLayout in six layouts

Preface In the last issue, we explained LinearLay...

HTML table tag tutorial (27): cell background image attribute BACKGROUND

We can set a background image for the cell, and w...

JavaScript to dynamically load and delete tables

This article shares the specific code of JavaScri...

HTML+CSS3 code to realize the animation effect of the solar system planets

Make an animation of the eight planets in the sol...

Let's talk about the performance of MySQL's COUNT(*)

Preface Basically, programmers in the workplace u...

How to clear mysql registry

Specific method: 1. Press [ win+r ] to open the r...

MyBatis dynamic SQL comprehensive explanation

Table of contents Preface Dynamic SQL 1. Take a l...

JavaScript parseInt() and Number() difference case study

Learning objectives: The two functions parseInt()...

How to reduce the root directory of XFS partition format in Linux

Table of contents Preface System environment Curr...