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

HTML input file control limits the type of uploaded files

Add an input file HTML control to the web page: &...

Detailed steps to build a file server in Windows Server 2012

The file server is one of the most commonly used ...

In-depth analysis of the diff algorithm in React

Understanding of diff algorithm in React diff alg...

A detailed account of the process of climbing a pit of Docker deployment service

First time writing. Allow me to introduce myself....

Vue uses rules to implement form field validation

There are many ways to write and validate form fi...

MySQL starts slow SQL and analyzes the causes

Step 1. Enable MySQL slow query Method 1: Modify ...

MySQL index optimization: paging exploration detailed introduction

Table of contents MySQL Index Optimization Paging...

Native JS to achieve book flipping effects

This article shares with you a book flipping effe...

Specific operations of MYSQL scheduled clearing of backup data

1|0 Background Due to project requirements, each ...

A very detailed summary of communication between Vue components

Table of contents Preface 1. Props, $emit one-way...

MySQL installation tutorial under Windows with pictures and text

MySQL installation instructions MySQL is a relati...

Vue-CLI multi-page directory packaging steps record

Page directory structure Note that you need to mo...

Introduction to general_log log knowledge points in MySQL

The following operation demonstrations are all ba...