Resetting MySQL root password in ubuntu 17.10, 重設MySQL 的root 密碼

我忘記了MySQL的root 密碼, 因為太久沒用了, 網路上找到了改密碼的程序, 先記下來, 下次也許用的到.

sudo /etc/init.d/mysql stop

再來這二個動作超重要, 我就是沒有做到, 卡關超久.
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/

再來就是起動mysql, 進入安全模式
sudo mysqld_safe –skip-grant-tables &

登入root, 不用密碼, 如果可以登入大概就沒什麼問題了.
sudo mysql -u root

選db 到mysql
use mysql;

執行改root密碼的sql command
update user set authentication_string=PASSWORD(“New_Passwore_Here”) where User=’root’;

flush privileges;


sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

sudo mysql -u root -p

喔! 成功.

GRUB installation failed

GRUB installation failed
The ‘grub-efi-amd64-signed’ package failed to install into /target/. Without the GRUB boot loader, the installed system will not boot.


Boot from LiveUSB or just got the error

1.mount /:

sudo mount /dev/sdXY /mnt

2.mount /boot/efi:

sudo mount /dev/sdXZ /mnt/boot/efi

3.mount other path:

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done

4.swith to root in /:

sudo chroot /mnt

5.install grub in disk:

grub-install /dev/sdX

6.update grub:


7.exit root

hit Ctrl+D to exit the chroot environment.

8.reboot and test



Device Start End Sectors Size Type
/dev/sda1 2048 411647 409600 200M EFI System
/dev/sda2 411648 500117503 499705856 238.3G Linux filesystem

Device Start End Sectors Size Type
/dev/sdb1 2048 20971519 20969472 10G Linux swap
/dev/sdb2 20971520 1953523711 1932552192 921.5G Linux filesystem


peppermint@peppermint ~ $ sudo mount /dev/sda2 /mnt
peppermint@peppermint ~ $ sudo mount /dev/sda1 /mnt/boot/efi
peppermint@peppermint ~ $ for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
peppermint@peppermint ~ $ sudo chroot /mnt
root@peppermint / # grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
root@peppermint / # update-grub
Generating grub configuration file …
Found background image: grub-background.png
Found linux image: /boot/vmlinuz-4.4.0-66-generic
Found initrd image: /boot/initrd.img-4.4.0-66-generic
Found linux image: /boot/vmlinuz-4.4.0-51-generic
Found initrd image: /boot/initrd.img-4.4.0-51-generic
grub-probe: error: cannot find a GRUB drive for /dev/sdc1. Check your
root@peppermint / # exit
peppermint@peppermint ~ $