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
相关文章
|
14天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源
|
17天前
|
Linux
linux下搭建tftp服务器教程
在Linux中搭建TFTP服务器,需安装`tftp-server`(如`tftpd-hpa`)。步骤包括:更新软件包列表,安装`tftpd-hpa`,启动并设置开机自启,配置服务器(编辑`/etc/default/tftpd-hpa`),添加选项,然后重启服务。完成后,可用`tftp`命令进行文件传输。例如,从IP`192.168.1.100`下载`file.txt`: ``` tftp 192.168.1.100 <<EOF binary put file.txt quit EOF ```
28 4
|
13天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
17 0
|
3天前
|
网络协议 安全 Linux
IDEA通过内网穿透实现固定公网地址远程SSH连接本地Linux服务器
IDEA通过内网穿透实现固定公网地址远程SSH连接本地Linux服务器
|
6天前
|
存储 关系型数据库 MySQL
Linux | MySQL基础
Linux | MySQL基础
|
6天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
19 0
|
9天前
|
Linux 数据安全/隐私保护
Linux基础与服务器架构综合小实践
【4月更文挑战第9天】Linux基础与服务器架构综合小实践
1220 8
|
21天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器
|
22天前
|
Linux
Linux安装bind9搭建自己的域名服务器
Linux安装bind9搭建自己的域名服务器
11 0
|
11天前
|
NoSQL Linux Shell
常用的 Linux 命令
常用的 Linux 命令
33 9