Devdit
 

MySQL/MariaDB ลืม password root วิธี reset password

1.6K

MySQL/MariaDB ลืม password root วิธี reset password บทความนี้สอนการ reset password ฐานข้อมูล MySQL และ MariaDB สามารถนำไปใช้ในกรณีลืม password หรือต้องการ reset password มีขั้นตอนดังนี้

 

ตัวอย่าง MySQL/MariaDB ลืม password root วิธี reset password

1. กด Windows + R พิมพ์ cmd แล้วกด enter

 

2. พิมพ์คำสั่ง mysql -u root เพื่อเข้าสู่ระบบฐานข้อมูล

C:\Users\admin>mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.4.19-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

3. พิมพ์คำสั่ง FLUSH PRIVILEGES เพื่อโหลดตารางการให้สิทธิ์ผู้ใช้งานฐานข้อมูลใหม่

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

 

4. ใช้คำสั่ง ALTER USER เพื่อ reset password ของ root

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';

 

5. ทดลองเข้า MySQL/MariaDB ด้วย account root และรหัสผ่านใหม่ที่ reset ในขั้นตอนที่ 4

D:\xampp\mysql\bin>mysql -uroot -p
Enter password: *****
Welcome to the MariaDB monitor.  Commands end with ; or \g.
แก้ไข 1 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ