CentOS7 下 MySQL 5.7 重置root密码

本文节选自《Netkiller MySQL 手札》

CentOS 7.x

添加 skip-grant-tables=1 选项,然后重启mysql

# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[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.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables=1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid		
		# systemctl restart mysqld		
		update mysql.user set authentication_string=password('netkiller') where user='root' and Host = 'localhost';
flush privileges;
quit;		
		# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update mysql.user set authentication_string=password('netkiller') where user='root' and Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye		

删除 skip-grant-tables=1 重启MySQL

原文发布于微信公众号 - Netkiller(netkiller-ebook)

原文发表时间:2016-10-09

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏散尽浮华

Gitlab备份和恢复操作记录

前面已经介绍了Gitlab环境部署记录,这里简单说下Gitlab的备份和恢复操作记录: 1)Gitlab的备份目录路径设置 [root@code-server ...

2488
来自专栏bboysoul

linux编译安装apache

wget http://mirrors.ustc.edu.cn/apache/httpd/httpd-2.4.25.tar.gz tar -zxvf http...

663
来自专栏散尽浮华

Docker环境编译时的两个错误记录

1093
来自专栏王硕

原 架设mediawiki服务器续--安装VisualEditor编辑器

3198
来自专栏SnailTyan

Linux下Caffe、Docker、Tensorflow、PyTorch环境搭建(CentOS 7)

注:模型的训练、测试、部署都可以通过Docker环境完成,环境问题会更少。 1. CUDA 8.0安装 ? Config env variables # CUD...

2930
来自专栏散尽浮华

open-falcon ---安装Dashboard时候报错"SSLError: The read operation timed out"

在部署open-falcon环境过程中,安装Dashboard时候报错"SSLError: The read operation timed out"。如下: ...

2297
来自专栏李蔚蓬的专栏

1.Android系统源代码目录与系统目录

想要看完整个Android的源代码,需要懂C、懂脚本、懂Java、软硬兼通。所以一般情况下,我们了解源代码的框架结构,出了问题知道从哪里着手解决就可以了。这就好...

692
来自专栏逸鹏说道

★Kali信息收集~3.子域名系列

★3.1Netcraft :子域名查询 官网:http://searchdns.netcraft.com/ 输入要查询的域名,即可得知子域名 ? 3.2Fie...

2405
来自专栏点点滴滴

windows平台KMS激活秘钥

1053
来自专栏blog

快速安装 Helm

Helm 是 Kubernetes 的包管理器,可以帮我们简化 kubernetes 的操作,一键部署应用。假如你的机器上已经安装了 kubectl 并且能够操...

1232

扫描关注云+社区