mysql重置密码

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

mysql重置密码

wulilideMacBook-Pro:bin wulili$ mysql start

ERROR 1045 (28000): Access denied for user 'wulili'@'localhost' (using password: NO)

wulilideMacBook-Pro:bin wulili$ su - root

1、吧mysql服务关闭

2、

 启动mysqld_safe ,跳过启动授权表。启动时加上skip-grant-tables参数目的是在启动mysql时不启动grant-tables,授权表。这样就可以修改root的密码了。

# mysqld_safe --skip-grant-tables &


wulilideMacBook-Pro:support-files root# find / -name mysqld_safe

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe

wulilideMacBook-Pro:support-files root# /usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe --skip-grant-tables &

[1] 1397

wulilideMacBook-Pro:support-files root# 2016-11-30T11:47:40.6NZ mysqld_safe Logging to '/usr/local/mysql/data/wulilideMacBook-Pro.local.err'.

2016-11-30T11:47:40.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

mysql -uroot -p

Enter password: 按下回车键

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.16 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 user set password=PASSWORD('12345678') where user="root"; 

ERROR 1046 (3D000): No database selected

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Database changed

mysql> update user set password=PASSWORD('12345678') where user="root"; 

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

mysql> update user set passwd=PASSWORD('12345678') where user="root"; 

ERROR 1054 (42S22): Unknown column 'passwd' in 'field list'

mysql> update user set password=password('12345678') where User='root';

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

mysql> update user set authentication_string=password('12345678') where user="root";

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 1


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


mysql> quit

Bye

3、重启数据库


wulilideMacBook-Pro:support-files root# /usr/local/mysql/support-files/mysql.server restart

Shutting down MySQL

..2016-11-30T11:58:22.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/wulilideMacBook-Pro.local.pid ended

 SUCCESS! 

Starting MySQL

. SUCCESS! 

[1]+  Done                    /usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe --skip-grant-tables

wulilideMacBook-Pro:support-files root# mysql -u root -p  这里密码就是12345678了

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.16


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> quit

Bye

wulilideMacBook-Pro:support-files root# 




mysql> use mysql;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql>  alter user 'root'@'localhost' identified by '12345678';

Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)




django.db.utils.OperationalError: (1862, 'Your password has expired. To log in you must change it using a client that supports expired passwords.')

mysql> SET PASSWORD=PASSWORD('123456');

Query OK, 0 rows affected, 1 warning (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


mysql> quit

Bye

wulilideMacBook-Pro:automaticdjango wulili$ /usr/local/mysql/support-files/mysql.server restart


必须要用下面方式python才能够识别到

mysql> SET PASSWORD=PASSWORD('123456');

Query OK, 0 rows affected, 1 warning (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


mysql> quit

Bye

wulilideMacBook-Pro:automaticdjango wulili$ /usr/local/mysql/support-files/mysql.server restart



本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1878274

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
关系型数据库 MySQL 数据安全/隐私保护
mysql重置密码
mysql重置密码
|
5月前
|
关系型数据库 MySQL 数据库
win10mysql搭建与重置密码
win10mysql搭建与重置密码
38 0
|
关系型数据库 MySQL Linux
linux下mysql 8.0忘记密码后重置密码
linux下mysql 8.0忘记密码后重置密码
191 0
|
6月前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL忘记密码后重置密码
MySQL忘记密码后重置密码
51 0
|
6月前
|
关系型数据库 MySQL 开发工具
Mysql 忘记密码怎么重置密码(详细步骤)
Mysql 忘记密码怎么重置密码(详细步骤)
658 0
|
关系型数据库 MySQL 数据库
MySQL忘记密码的处理方法(MySQL重置密码)
本文主要讲解MySQL如何重置密码(MySQL密码重置方法)
83511 2
MySQL忘记密码的处理方法(MySQL重置密码)
|
关系型数据库 MySQL 数据库
Mysql修改与重置密码
Mysql修改与重置密码
153 0
|
关系型数据库 MySQL 开发工具
Mysql 忘记密码怎么重置密码(详细步骤)
Mysql 忘记密码怎么重置密码(详细步骤)
925 0
|
关系型数据库 MySQL 数据安全/隐私保护
mysql解决:当你要重置密码时报错Your password does not satisfy the current policy requirements
mysql解决:当你要重置密码时报错Your password does not satisfy the current policy requirements
125 0
|
存储 关系型数据库 MySQL
手把手教你MySQL 重置密码
手把手教你MySQL 重置密码
414 0