CentOS7.4 installing MySQL pit record
time:2018.3.19
CentOS7.4 install MySQL online documents although many but not reliable also many, may because of the version and time of the problem, so record their own step on the pit process, if you find into the pit, welcome to reference this article:)
Try uninstalling Reinstall, reference, step:
1. See if Yum has installed MySQL
yum list installed mysql*
yum list installed | grep mysql*
No results are displayed stating that there is no MySQL installed in Yum (not very well known for Yum and RPM, if there is a mistake, please note)
2. Delete the configuration files and folders
rm -rf /var/lib/mysql
rm /etc/my.cnf
3. View the installation and uninstall in rpm
rpm -qa | grep -i mysql
The following list changes are shown according to the above command
rpm -e mysql-community-server-5.7.21-1.el7.x86_64 mysql-community-common-5.7.21-1.el7.x86_64 mysql-community-libs-5.7.21-1.el7.x86_64 mysql57-community-release-el7-11.noarch mysql-community-client-5.7.21-1.el7.x86_64 mysql-community-libs-compat-5.7.21-1.el7.x86_64 --nodeps
3. Clear the remainder
whereis mysql
Remove the path shown by the above command
rm -rf /usr/share/mysql/
4. Delete the configuration
rm -rf /usr/my.cnf
rm -rf /root/.mysql*
# no results
# 笔者机器上无结果chkconfig --list | grep -i mysqlchkconfig --del mysqldsystemctl list-dependencies | grep -i mysql
5.
Re-install
Download the MySQL source and install to RPM:
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpmrpm -ivh mysql57-community-release-el7-11.noarch.rpm
Update yum and install MySQL (longer):
# 更新yum软件包yum check-update# 更新系统yum update# 安装mysqlyum install mysql mysql-server
Precautions
You may need to re-edit the file header after updating Yum /usr/bin/yum
(because I changed the default Python to Python3), and then install it again after editing, and the following error occurs:
[[email protected] ~]# yum install mysql mysql-server File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^SyntaxError: invalid syntax
configuration after installation is complete
grant-tables
starting MySQL When the authorization table has not been skipped appears:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
The
need to change the root password, this command is to add a boot parameter to MySQL --skip-grant-tables
, as the name implies, is not started when you start MySQL grant-tables
Authorization table for forgetting Administrator password modifications
/usr/local/mysql/bin/mysqld_safe--skip-grant-tables--user=mysql &
However, the MySQL 5.7.6
version begins by default, Mysqld_safe
is not installed, and the following is the new method: 1. Stop MySQL service
Service mysqld Stop
2. Set mysqld options --skip-grant-tables
parameters:
systemctl set-environment mysqld_opts= '-- Skip-grant-tables '
3. Restart MySQL
systemctl start mysqld
4. Execute mysql-u Root
log in to MySQL and change password
[[email protected] ~]# mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.21 MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> UPDATE mysql.user -> SET authentication_string = PASSWORD(‘toor‘), password_expired = ‘N‘ -> WHERE User = ‘root‘ AND Host = ‘localhost‘;Query OK, 1 row affected, 1 warning (0.65 sec)Rows matched: 1 Changed: 1
password_expired = ‘N‘
The expiration status is set to No, flush privileges;
refresh the permission record, see
5. After setting the password, remove the --skip-grant-tables
parameters, restart the password of the available settings login to the root user
systemctl unset-environment MYSQLD_OPTS
systemctl restart mysqld
mysql -uroot -p
Since the author code is running on the server system, it is not set to MySQL remote access
CentOS7.4 installing MySQL pit record