一、安装与配置
[root@mysql1 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
https://downloads.mysql.com/archives/community/ #下载地址
[root@mysql1 tools]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
错误:依赖检测失败:
mysql-community-libs(x86-64) >= 5.7.9 被
mysql-community-client-5.7.18-1.el7.x86_64 需要
[root@mysql1 tools]# rpm -ivh
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
错误:依赖检测失败:
mysql-community-common(x86-64) >= 5.7.9 被mysql-community-libs-5.7.18-1.el7.x86_64 需要
[root@mysql1 tools]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
准备中...
################################# [100%]
正在升级/安装...
1:mysql-community-common-5.7.18-1.e#################################
[100%]
[root@mysql1 tools]# rpm -ivh
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
准备中...
################################# [100%]
正在升级/安装...
1:mysql-community-libs-5.7.18-1.el7#################################
[100%]
[root@mysql1 tools]# rpm -ivh
mysql-community-client-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
准备中...
################################# [100%]
正在升级/安装...
1:mysql-community-client-5.7.18-1.e#################################
[100%]
[root@mysql1 tools]# rpm -ivh
mysql-community-server-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1
Signature, 密钥
准备中...
################################# [100%]
正在升级/安装...
1:mysql-community-server-5.7.18-1.e#################################
[100%]
[root@mysql1 tools]# mysql -h localhost -u
root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@mysql1 tools]# ln -s /var/lib/mysqld/mysqld.sock /tmp/mysql.sock
[root@mysql1 tools]# lsof -i:3006
[root@mysql1 tools]# service mysqld status
Redirecting to /bin/systemctl status
mysqld.service
●
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor
preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@mysql1 tools]# systemctl start
mysqld.service
[root@mysql1 tools]# systemctl restart
mysqld.service
二、如何重置root密码
[root@mysql1 tools]# mysql -uroot
ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: NO)
[root@mysql1 tools]# vi /etc/my.cnf
[mysqld]
#
# Remove leading # and set to the amount of
RAM for the most important data
# cache in MySQL. Start at 70% of total RAM
for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very
important data integrity option: logging
# changes to the binary log between
backups.
"/etc/my.cnf" 27L, 960C
# For advice on how to change settings
please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended
to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-grant-tables
[root@mysql1 tools]# service mysqld restart
[root@mysql1 tools]# mysql
mysql>
mysql> use mysql
mysql> update user set
password=password('****') where user='root';
mysql> flush privileges;
mysql>exit;
[root@mysql1 ~]# vi /etc/my.cnf
skip-grant-tables #删除掉
#service restart mysqld #重新启动服务即可。
标签:mysql1,操作系统,5.7,rpm,Linux,community,mysql,MySQL,root
From: https://blog.51cto.com/sky9896/7447916