# 树莓派忘记密码如何重设

## Step 1 – Grab The SD Card

Power down the Pi and remove the SD card. Insert it into your PC.

## Step 2 – Edit cmdline.txt

The boot partition should be visible and contain a file named “cmdline.txt”. Edit this file in a text editor and add the following to the end of the existing text :

init=/bin/sh

If the original content was :

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

it should now look like :

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh

Make sure it is all one line! Save the text file and eject the SD card from the PC.

## Step 3 – Reset the Password

Insert the card into a Pi that is connected to a monitor and keyboard. Power up the Pi. There may be a delay but you should be presented with a flashing cursor.

将sd卡插入树莓派（我们在这里需要连上显示器和键盘）。将树莓派开机，估计在显示闪动的光标前需要等一会。

At the prompt type the following command :

passwd pi

You will then be prompted for a new password. Enter it carefully and press the [Return] key. It will now ask you to retype the password.

passwd pi

Now type the following commands :

sync
exec /sbin/init

The Pi will continue to boot and return you to the normal command line prompt.

Shutdown the Pi and power it off.

sudo halt

## Step 4 – Edit cmdline.txt

Using the PC edit the “cmdline.txt” file again and remove the “init=/bin/sh” text you added in Step 2.

You can now return the SD card to your Pi, reboot and use the new password.

#### 在树莓派上安装MySQL数据库和简单使用方法

2015-11-09 11:29:49

#### 树莓派安装MySQL并进行远程登录

2016-11-06 15:27:02

#### [Mysql]查看mysql默认密码

2017-03-29 13:08:18

#### 树莓派忘记密码

2016-03-26 00:04:29

#### 昨天突然想远程登陆vnc，控制树莓派，结果忘记密码了！！！

2017-03-02 09:34:32

#### 树莓派 忘记密码的解决方法

2017-03-02 13:55:47

#### 树莓派3B+ 破解Wi-Fi密码

2018-01-29 15:09:54

#### 树莓派 Learning 002 装机后必要的操作 --- 09 root用户 密码

2016-08-06 03:11:32

#### 树莓派Raspbian系统密码设置

2017-08-07 18:52:46

#### 修改树莓派用户密码

2017-12-09 17:30:19