วิธีเปลี่ยน root password database mysql บน ubuntu

 หลังจาก install mysql บน ubuntu ไปแล้วเจอปัญหาว่า จำ root password ไม่ได้ วิธีแก้ง่ายๆ ครับ

สร้าง User ใหม่มันซะเลยด้วย Step ต่อไปนี้ครับ

sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 8.0.34-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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> create user 'myadmin'@'localhost' IDENTIFIED BY 'mypassword';
Query OK, 0 rows affected (0.02 sec)

mysql> grant all privileges on *.* to 'myadmin'@'localhost';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit; 


อ่ะแล้วถ้าเราไม่อยากสร้างใหม่ล่ะเราแค่อยาก เปลี่ยน password root ของ mysql ให้ run คำสั่ง alter ตามนี้เลยคับ

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'new_password';

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

Oracle date format จัด format date ให้แสดง พศ และ เดือน ภาษาไทยหรือตามภาษาที่เราเลือก

java -Xms , java -Xmx กำหมด memory ให้ JVM เพื่อป้องกันปัญหา Out of Memory

Java this กับ super การใช้งานคำสั่ง this กับ super ใน ภาษา Java