Install mysql5.7 under centos7.2, use RPM package to install

Source: Internet
Author: User
Tags safe mode uuid mysql login

Environment:

CentOS Linux release 7.2.1511 (Core)

mysql-5.7.18

1 Uninstall mariadb-lib prior to installation

[Email protected] ~]#  rpm-qa|grep mariadb mariadb-libs-5.5.44-2.el7.centos.x86_64 [[email protected] ~]#  rpm -E mariadb-libs-5.5.44-2.el7.centos.x86_64--nodeps

2 Go to the official website to download the latest RPM package: Mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

Extract the Rpm-bundle.tar, actually only need to install the following several packages

[Email protected] ~]#  RPM-IVH mysql-community-common-5.7.16-1.el7.x86_64.rpm [[email protected] ~]#  RPM-IVH Mysql-community-libs-5.7.16-1.el7.x86_64.rpm[[email protected] ~]#  RPM-IVH mysql-community-client-5.7.16-1.el7.x86_64.rpm [[email protected] ~]#  RPM-IVH mysql-community-server-5.7.16-1.el7.x86_64.rpm

The above several packages have the dependency, the execution has successively.

To install MySQL using the RPM installation, the installation path is as follows:

A database directory
/var/lib/mysql/
B configuration File
/usr/share/mysql (mysql.server command and configuration file)
C Related Commands
/usr/bin (Mysqladmin mysqldump and other commands)
D Startup script
/etc/rc.d/init.d/(startup script file for MySQL directory)

3 Database Initialization

In order to ensure that the database directory is the owner of the file with the MySQL login user, if you are running the MySQL service as root, you need to perform the following command initialization

[Email protected] ~]#  mysqld--initialize--user=mysql

If you are running as MySQL, you can remove the--user option .

In addition, the--initialize option is initialized in "safe" mode by default, a password is generated for the root user and the password is marked as expired, and you need to set a new password after logging in.

While using the--initialize-insecure command does not use Safe mode, a password is not generated for the root user.

This demo uses the--initialize initialized, will generate a root account password, the password in the log file, the red area is the auto-generated password

 [[email protected] ~]# cat/var/log/ Mysqld.log  2017-04-13t10:00:36.294549z 0 [Warning] TIMESTAMP with implicit the DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-04-13t10:0 0:36.848923z 0 [Warning] innodb:new log files created, lsn=457902017-04-13t10:00:36.961351z 0 [Warning] innodb:creating  FOREIGN KEY constraint system tables.2017-04-13t10:00:37.153654z 0 [Warning] No existing UUID have been found, so we assume That's the first time that this server has been started. Generating a new uuid:0ae74223-2030-11e7-abde-08002774d86f.2017-04-13t10:00:37.185725z 0 [Warning] Gtid table is not rea Dy to be used. Table ' mysql.gtid_executed ' cannot be opened.2017-04-13t10:00:37.229524z 1 [Note] A temporary password are generated for [E Mail protected]: %kwtz,ml?3zs   

Start MySQL database now systemctl start Mysqld.service

[Email protected] ~]# systemctl start Mysqld.service

You can use the following two commands to stop, start, and restart MySQL:

Start:

Start with service: Service mysqld start using mysqld script:/etc/inint.d/mysqld start using safe_mysqld boot:safe_mysqld&

Stop it:

Restart:

Use service startup: Service mysqld Restart start with mysqld script:/etc/inint.d/mysqld restart

Connecting to a database

mysql-u root-p Enter Password:

Password input:%kwtz,ml?3zs

Change Password:

ALTER USER ' root ' @ ' localhost ' identified by ' new_password ';

Because my Linux centos7 is installed on the virtual machine, I need to use the host remote access to MySQL, the connection to MySQL 1045 error occurred.

Workaround:

mysql> use MySQL; Mysql> select Host,user from user;

Need to re-edit:

Linux connection MySQL 1045 Error resolution
Get the following results +---------------+------+ | Host | user | +---------------+------+ | localhost | Root | +---------------+------+ 5 rows in Set (0.00 sec) discovers that the root user only allows local (localhost) logins, and if you want to telnet to the MySQL server, you need to create a new user with normal permissions. The new user uses the following command: Mysql> Grant Select,update,insert,delete on mas.* to [email protected] identified by "123456"; This command means: Create a new user Duan and only allow the user to log on locally (localhost), the password is 123456, and give it permission to select,update,insert all tables in the MAS library. We have a MAS library here, so we use mas.* to represent all the tables under the MAS library. Now the Duan user, can log in to MySQL, but also can only log on locally. To Duan users to telnet to MySQL, you also need the following command: mysql> update user Set host = '% ' where user = ' Duan '; now we look at MySQL's management library: Mysql> Select Host,user from user; +-----------+------+ | Host | user | +-----------+------+ | % | Duan | | localhost | Root | +-----------+------+ 5 rows in Set (0.00 sec) At this point, create a new connection on Mysql-front, enter the connection name, the remote Linux IP address, enter the user name Duan and password 123456, select the connection port, MySQL default is 3306, or the connection is not on. After multiple searches, it was found that mysql> flush privileges was also required; After the cache was flush, it was finally done. Because the UPDATE statement is used to modify user records, the flush statement is also required to tell the server to overload the authorization table. When you use the GRANT and REVOKE statements, the table is automatically overloaded, not when you modify the authorization table directly. So the easier way is mySql> Grant Select,update,insert,delete on mas.* to [email protected] "%" identified by "123456";

Install mysql5.7 under centos7.2, use RPM package to install

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.