วันศุกร์ที่ 27 เมษายน พ.ศ. 2555
วันอาทิตย์ที่ 1 เมษายน พ.ศ. 2555
ถ้าลืม Password ของ MySQL จะทำอย่างไร
มีความเป็นไปได้มากกับการลืมรหัสผ่านของ user root ของ MySQL ไม่ต้องตกใจครับมีวิธีการแก้ปัญหา
ดังคำาสั่งดังต่อไปนี้
# /etc/init.d/mysqld stop
# /usr/bin/mysqld_safe user=
root skipgranttables
&
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> UPDATE mysql.user SET Password = PASSWORD('newpassword‘) WHERE
User = 'root';
mysql> FLUSH PRIVILEGES;
mysq> \q
# mysqladmin shutdown
# /etc/init.d/mysqld start
จะเห็นว่าเราต้องหยุดการทำางานของ MySQL ก่อน แล้วจึงสั่งให้ MySQL ทำางานอีกครั้งหนึ่งโดยใช้ ออปชัน
skipgranttables
หลังจากนั้นก็สามารถเข้าใช้งาน MySQL ได้โดยไม่ต้องใส่รหัสผ่าน เมื่อเข้ามาได้แล้ว
ก็ทำาการเปลี่ยนรหัสผ่านโดยใช้คำาสั่ง update
ดังคำาสั่งดังต่อไปนี้
# /etc/init.d/mysqld stop
# /usr/bin/mysqld_safe user=
root skipgranttables
&
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> UPDATE mysql.user SET Password = PASSWORD('newpassword‘) WHERE
User = 'root';
mysql> FLUSH PRIVILEGES;
mysq> \q
# mysqladmin shutdown
# /etc/init.d/mysqld start
จะเห็นว่าเราต้องหยุดการทำางานของ MySQL ก่อน แล้วจึงสั่งให้ MySQL ทำางานอีกครั้งหนึ่งโดยใช้ ออปชัน
skipgranttables
หลังจากนั้นก็สามารถเข้าใช้งาน MySQL ได้โดยไม่ต้องใส่รหัสผ่าน เมื่อเข้ามาได้แล้ว
ก็ทำาการเปลี่ยนรหัสผ่านโดยใช้คำาสั่ง update
สมัครสมาชิก:
ความคิดเห็น (Atom)