Cách chuyển đổi phiên bản mặc định của MariaDB
Trong một số trường hợp, bạn có thể cần nâng cấp hoặc chuyển đổi phiên bản của MariaDB để tận dụng các tính năng mới hoặc cập nhật bảo mật. Bài viết này sẽ hướng dẫn chi tiết cách chuyển đổi phiên bản mặc định của MariaDB trong môi trường ServBay. Sau đây là các bước cụ thể:
TIP
Dưới đây sẽ lấy ví dụ chuyển đổi từ MariaDB 10.11 sang MariaDB 11.3
1. Trước tiên, sao lưu cơ sở dữ liệu phiên bản cũ
Trước khi chuyển đổi phiên bản MariaDB, đề nghị sao lưu cơ sở dữ liệu hiện có để phòng ngừa mất dữ liệu. Bạn có thể dùng lệnh mysqldump
để sao lưu tất cả cơ sở dữ liệu một cách dễ dàng.
mysqldump -uroot -p --all-databases --opt > mariadb_backup.sql
Khi thực hiện lệnh này, hệ thống sẽ yêu cầu nhập mật khẩu của người dùng root MariaDB. Sau khi sao lưu hoàn tất, bạn sẽ thấy một tệp tin mariadb_backup.sql
trong thư mục hiện tại.
2. Cài đặt phiên bản mới cần sử dụng, ví dụ MariaDB 11.3
Trên bảng điều khiển quản lý của ServBay, tìm phần quản lý cơ sở dữ liệu, chọn MariaDB và nhấp vào cài đặt phiên bản mới mà bạn cần (ví dụ, MariaDB 11.3).
3. Vô hiệu hóa phiên bản cũ, ví dụ MariaDB 10.11
Sau khi cài đặt phiên bản mới, bạn cần vô hiệu hóa phiên bản cũ để đảm bảo hệ thống sử dụng phiên bản mới của MariaDB. Tìm phiên bản cũ (ví dụ, MariaDB 10.11) và vô hiệu hóa nó.
4. Kích hoạt phiên bản mới và xác nhận dịch vụ hoạt động bình thường
Sau khi vô hiệu hóa phiên bản cũ, kích hoạt phiên bản mới của MariaDB và đảm bảo dịch vụ của nó hoạt động bình thường.
5. Trong bảng cài đặt, chuyển phiên bản mặc định từ MariaDB 10.11 sang MariaDB 11.3, nhấp "Apply"
Tiếp theo, bạn cần chuyển phiên bản mặc định sang phiên bản mới trong bảng cài đặt. Chọn MariaDB 11.3 và nhấp "Apply" để áp dụng thay đổi.
6. Quay lại bảng dịch vụ, thấy phiên bản mặc định đã được đặt thành công
Trong bảng dịch vụ, bạn sẽ thấy phiên bản mặc định đã được chuyển đổi thành công sang MariaDB 11.3.
7. Trở lại dòng lệnh, nhập mysql -V
, bạn sẽ thấy phiên bản đã chuyển đổi thành 11.3.2
Nhập lệnh sau trong dòng lệnh để xác nhận rằng phiên bản MariaDB đã được chuyển đổi thành công:
mysql -V
Kết quả đầu ra sẽ hiển thị phiên bản hiện tại của MariaDB là 11.3.2.
8. Khôi phục cơ sở dữ liệu
Sau khi chuyển đổi phiên bản, bạn cần khôi phục cơ sở dữ liệu đã sao lưu trước đó. Sử dụng lệnh sau để khôi phục cơ sở dữ liệu:
mysql -uroot -p < mariadb_backup.sql
Hệ thống sẽ yêu cầu nhập mật khẩu của người dùng root MariaDB. Sau khi nhập mật khẩu, quá trình khôi phục cơ sở dữ liệu sẽ bắt đầu.
9. Xác nhận cơ sở dữ liệu đã khôi phục hoàn toàn
Để đảm bảo cơ sở dữ liệu đã khôi phục hoàn toàn, bạn có thể đăng nhập vào MariaDB và kiểm tra xem dữ liệu có đầy đủ hay không:
mysql -uroot -p
Sau khi đăng nhập, bạn có thể sử dụng lệnh sau để xem danh sách cơ sở dữ liệu:
SHOW DATABASES;
Kiểm tra các cơ sở dữ liệu và bảng, đảm bảo dữ liệu đầy đủ và chính xác.
Bằng các bước trên, bạn đã thành công chuyển đổi phiên bản mặc định của MariaDB sang phiên bản mới và khôi phục cơ sở dữ liệu. Hy vọng bài viết này sẽ giúp bạn hoàn thành việc chuyển đổi phiên bản MariaDB một cách suôn sẻ.