Hướng dẫn lấy thông tin mật khẩu mặc định MySQL root trên Direct Admin

Hướng dẫn lấy mật khẩu mặc định trên Direct Admin. Trong DirectAdmin khi hoàn thành quá trình cài đặt, các tài khoản và thông tin mặc định được lưu vào một file setup.txt.
Hướng dẫn lấy thông tin mật khẩu mặc định MySQL root trên Direct Admin
Với MySQL mật khẩu cho user root cũng được thiết lập trong quá trình cài đặt và viết vào setup.txt. Nếu bạn không thay đổi mật khẩu này, bạn có thể tìm thấy thông tin trong setup.txt, sử dụng lệnh dưới đây để xem nội dung của tập tin này:

[root@server ~]# cat /usr/local/directadmin/scripts/setup.txt
hostname=server.vps157.vn
email=admin@server.vps157.vn
mysql=NtncEitn
mysqluser=da_admin
adminname=admin
adminpass=ayFbF9BX
ns1=ns1.vps157.vn
ns2=ns2.vps157.vn
ip=202.92.5.157
netmask=255.255.255.0
uid=vps157.vn
lid=vps157.vn
services=services_es60_64.tar.gz


Mật khẩu của user root được lưu trữ trong các dòng bắt đầu với mysql =

Ta có thể sử dụng mật khẩu đó để đăng nhập MySQL


[root@server ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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> 


Hướng dẫn cách đăng nhập MySQL không cần phải nhập password root

Nếu bạn muốn truy cập mysql từ ssh hoặc giao diện điều khiển trực tiếp tạo ra một tập tin trong /root/dir gọi .my.cnf:
 

[root@server ~]# touch /root/.my.cnf
 

Và chỉnh sửa lại :
 

[root@server ~]# vi /root/.my.cnf
 

Thêm các dòng dưới đây:

[client]
user=root
password=XXXXXX
 

Điền mật khẩu với đèo bạn nhận được từ setup.txt, lưu file :wq và thoát. Sau bước này chỉ cần viết mysql để nhập MySQL giao diện điều khiển trực tiếp mà không cần mật khẩu.

[root@server ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.5.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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>
 

Chúc bạn thực hiện thành công !