Install MySQL5.6.28 on CentOS7 and change its password

Source: Internet
Author: User

Install MySQL5.6.28 on CentOS7 and change its password

In the sophomore Linux course design, MySQL master-slave backup was performed based on CentOS7, and mariadb has been used on CentOS7 to replace MySQL. Therefore, mariadb is actually installed using yum install mysql.
MySQL needs to be installed for recent tests, and rpm is used based on the principle of speed
The system is CentOS7-1604-mini minimal installation version
1. Install the dependency and delete the lib library of mariadb. The default value is built-in.

yum install -y wget libaioyum remove  mariadb*

2. Download the MySQL RPM package

cd /tmp/ && wget -c http://downloads.mysql.com/archives/get/file/MySQL-5.6.28-1.linux_glibc2.5.x86_64.rpm-bundle.tar

3. decompress the tar package

cd /tmp/ && tar -xvf MySQL-5.6.28-1.linux_glibc2.5.x86_64.rpm-bundle.tar rm -rf /tmp/MySQL-5.6.28-1.linux_glibc2.5.x86_64.rpm-bundle.tar

4. Install related software

cd /tmp/ && rpm -ivh MySQL*

5. Start

Systemctl enable mysql # start systemctl start mysql from startup # start mysql

6. Change the password mysql will generate the following file at/root/. mysql_secret for security by default

[root@izltf35j605nncz user]# cat /root/.mysql_secret# The random password set for the root user at Sat Feb 25 14:50:11 2017 (local time): TjMBpQi0UeNWjUev

7. You can change the password in several ways. First, check the original configuration of mysql> select host, user, password from mysql. user;

HostUserPasswordLocalhostroot * handle. 0.0.1root * 4F5D16242740A35AC75396074A16FCA85E733DDE % sakila * handle % test * handle % root * handle

6 rows in set (0.00 sec)

1. Use set password for 'username' @ 'hostname '= password ('Password ');

set password for 'root'@'localhost'=password('123456')

Mysql> select host, user, password from mysql. user;

HostUserPasswordLocalhostroot * handle. 0.0.1root * 4F5D16242740A35AC75396074A16FCA85E733DDE % sakila * handle % test * handle % root * handle

6 rows in set (0.00 sec)

2. Use update to modify update mysql. user set password = password ('000000') where user = 'root ';

update mysql.user set password=password('123456') where user='root';

Mysql> select host, user, password from mysql. user;

HostUserPasswordLocalhostroot * login. 0.0.1root * 6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9% sakila * login % test * login % root * Login

6 rows in set (0.00 sec)

3. Use grant all privileges on sakila. * to 'sakila' @ '%' identified by '123'; Modify. Set Remote Access

grant all privileges on sakila.* to 'sakila'@'%' identified by '123456';

Mysql> select host, user, password from mysql. user;

HostUserPasswordLocalhostroot * login. 0.0.1root * 6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9% sakila * login % test * login % root * Login

6 rows in set (0.00 sec)

Note: When you first install and set a password, you must use update to change the password and change the root password. In this way, the passwords are the same when localhost or 127.0.0.1 is used. Otherwise, it may be different, resulting in unavailability. If the database server and web server are on the same server, try to use localhost. In linux, mysql uses a unix socket when using localhost, while others use the TCP/IP protocol.

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.