Linux installation MySQL 5.7.21 detailed and troubleshooting problems encountered during installation

Source: Internet
Author: User
Tags uuid

The problems encountered during the installation process are:
1. my-default.cnf File not found
2. mysql Start error
3. mysql temporary password cannot be logged in

Installation Environment CentOS 6.0
Download the database:
[Email protected] src]# pwd
/USR/LOCAL/SRC #下载文件存放路径 (for personal reasons, be free.) )
[Email protected] src]#
[Email protected] src]# TAR-ZXVF mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz #解压
[[Email protected] src]# mv mysql-5.7.21-linux-glibc2.12-x86_64 MySQL
To uninstall an older version:
[[email protected] src]# rpm-qa |grep MySQL
[Email protected] src]# rpm-e--nodeps mysql-5.1.47-4.el6.x86_64
[Email protected] src]# rpm-e--nodeps mysql-libs-5.1.47-4.el6.x86_64
[Email protected] src]# rpm-e--nodeps mysql-devel-5.1.47-4.el6.x86_64
[[email protected] src]# rpm-qa |grep MySQL
[Email protected] src]#

CREATE database directories and users and groups:
[[email protected] src] #mkdir/data
[[email protected] src] #mkdir/data/mysqldata #数据存放目录
[[email protected] src] #groupadd mysql #创建mysql组
[[email protected] src] #useradd-r-s/sbin/nologin-g MySQL mysql-d/usr/local/src/mysql #添加mysql用户使其shell模式为nologin (Forbidden Login),
[[email protected] mysql]# chown-r MySQL.
[[email protected] mysql]# chgrp-r MySQL.
[[email protected] MySQL] #chown-R mysq/data/mysqldata
Install the Numactl component before installation, or error: Bin/mysqld:error while loading shared
[Email protected] mysql]# yum-y install Numactl
(You can install it using the local CD Yum source, provided that it is built.) )
Configuration parameters:
[[Email protected] src]# CD MySQL
[Email protected] mysql]# bin/mysqld--initialize--user=mysql--basedir=/usr/local/src/mysql--datadir=/data/ mysqldata/#配置参数
2018-01-31t08:41:32.144065z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-31t08:41:34.501273z 0 [Warning] innodb:new log files created, lsn=45790
2018-01-31t08:41:34.943351z 0 [Warning] innodb:creating FOREIGN KEY constraint system tables.
2018-01-31t08:41:35.016168z 0 [Warning] No existing UUID have been found, so we assume that's the first time that thi s server has been started. Generating a new uuid:8b673fc1-0662-11e8-a70a-000c298536ba.
2018-01-31t08:41:35.021358z 0 [Warning] Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened.
2018-01-31t08:41:35.025019z 1 [Note] A temporary password is generated for [email protected]: dhamrqavz5-c {last [email prot Ected]: After the temporary password (I did not feel during the installation process, login not.) )}
--basedir=/usr/local/src/mysql #mysql文件所在目录

[Email protected] mysql]# Bin/mysql_ssl_rsa_setup--datadir=/data/mysqldata/

To modify the system configuration file:

The my-default.cnf file was not found in the Support-files directory, so it can only be created manually.
[[email protected] support-files]# vim/etc/my.cnf (Create MY.CNF, copy the following code, remember that the following directories need to manually modify their own defined directory)

Port = 3306
Socket =/tmp/mysql.sock

init_connect= ' SET NAMES UTF8 '
Basedir=/usr/local/src/mysql #文件存放目录
Lower_case_table_names = 1

Sql_mode=strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_ Engine_substitution

Default-time_zone = ' the ' "

[email protected] support-files]# CP Mysql.server/etc/init.d/mysql
[Email protected] support-files]# Vim/etc/init.d/mysql
Modify/etc/init.d/mysqld to fill in the file storage path and data storage path after Basedir and DataDir

start MySQL:
[Email protected] mysql]# bin/mysqld_safe--user=mysql & #检测

[[email protected] run]#/etc/init.d/mysql start (Error here, because the Mysqld folder cannot be found, so create and give permissions.) )

[Email protected] mysql]# cd/var/run/
[Email protected] run]# mkdir mysqld
[Email protected] run]# chown-r MySQL mysqld
[Email protected] run]# chgrp-r MySQL mysqld
[[email protected] run]#/etc/init.d/mysql start
Starting MySQL ... [OK]

login MySQL has changed password:
Since the attempt to use the MySQL temporary password can not log in, so the following directly into the configuration.
Modify the/etc/my.cnf file
Add "Skip-grant-tables" below [mysqld]

(The Skip-grant-tables command is to skip authentication and log in directly.) Personally think of Linux as a single-user mode for MySQL password modification. )
Restart MySQL

Enter MySQL on the command line to log in

mysql> show databases;
| Database |
| Information_schema |
| MySQL |
| Performance_schema |
| SYS |
4 rows in Set (0.00 sec)

mysql> use MySQL; #选择数据库
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a

Database changed
mysql> Update user Set Authentication_string=password (' 123abc ') where user= ' root ';
Query OK, 0 rows affected, 1 Warning (0.00 sec)
Rows matched:1 changed:0 warnings:1

mysql> flush Privileges; #刷新权限
Query OK, 0 rows Affected (0.00 sec)

Mysql> quit;
Log back in to MySQL
[[email protected] run] #mysql-uroot-p123abc

The last step unregisters "Skip-grant-tables" in my.cnf

Linux installation MySQL 5.7.21 detailed and troubleshooting problems encountered during installation

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: 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.