Linux服务器---mysql忘记密码

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
+关注继续查看
mysql忘记root密码
      如果不小心忘记了root密码,那么mysql就不能再登录了,这时就要重置root密码才行。通过下面的步骤,我们可以重新设置root密码。
1、退出mysql
      [root@localhost src]# service mysqld stop
      停止 mysqld:                                              [确定]
      [root@localhost src]# 

2、进入sql安全模式,命令“/usr/bin/mysqld_safe --skip-grant-table &”
      [root@localhost src]# /usr/bin/mysqld_safe --skip-grant-table &
      [1] 6332
      [root@localhost src]# 180814 10:10:00 mysqld_safe Logging to '/var/log/mysqld.log'.
      180814 10:10:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3、无密码方式登录,命令“mysql –u root”
      [root@localhost src]# mysql -u root
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 1
      Server version: 5.1.71 Source distribution
      Copyright (c) 2000, 2013, 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> 

4、使用mysql,命令“use mysql;” 
      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> 

5、重设root密码,命令“update user set password=password (“密码”) where user=’root’”
      mysql> update user set password=password('123456') where user='root';
      Query OK, 3 rows affected (0.00 sec)
      Rows matched: 3  Changed: 3  Warnings: 0
      mysql> 

6、刷新 
      mysql> flush privileges;
      Query OK, 0 rows affected (0.00 sec)

7、退出,重新登录
      [root@localhost src]# mysql -u root -p
      Enter password:        //这里输入新密码
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 2
      Sever version: 5.1.71 Source distribution
      Copyright (c) 2000, 2013, 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> 



相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
5天前
|
安全 Linux 数据安全/隐私保护
Linux 忘记密码解决方法
Linux 忘记密码解决方法
4 0
|
20天前
|
安全 Linux 数据安全/隐私保护
|
22天前
|
关系型数据库 MySQL Linux
linux下mysql 8.0忘记密码后重置密码
linux下mysql 8.0忘记密码后重置密码
|
1月前
|
弹性计算 安全 Linux
Linux的root账号忘记密码怎么办?看这一篇就够了!
今天上班的时候有个小伙伴说他管理的一台服务器密码给搞忘了,因为之前做过基线,试了5次就给封了半个小时,现在又急着要上去部署,我啪的一下很快啊,直接甩出了这篇文章。
|
2月前
|
安全 Linux 数据安全/隐私保护
Linux 忘记密码解决方法
Linux 忘记密码解决方法
|
2月前
|
Linux Shell 数据安全/隐私保护
linux忘记密码怎么办
linux忘记密码怎么办
22 0
|
3月前
|
关系型数据库 MySQL Linux
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
46 0
|
6月前
|
安全 Linux 数据安全/隐私保护
Linux root用户忘记密码解决方法
Linux root用户忘记密码解决方法
1538 0
|
7月前
|
Linux 数据安全/隐私保护
Linux 改动inittab文件及忘记密码等导致无法进入系统的解决办法
Linux 改动inittab文件及忘记密码等导致无法进入系统的解决办法
65 0
|
11月前
|
Linux 数据安全/隐私保护
centos linux忘记密码进行重置
centos linux忘记密码进行重置
推荐文章
更多