Cập nhật Maria DB cho hocvps

Để kiểm tra phiên bản MariaDB hiện đang chạy bạn dùng lệnh

mysql -u admin -p

Trong đó admin là username HocVPS của bạn, nhập pass vào bạn nhận được những thông tin sau:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2263
Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Như vậy hiện tại phiên bản MariaDB của mình là 10.0 trong khi bản mới nhất Stable Version là 10.4 và 10.5 cho phiên bản Beta => Quá cũ cho một cuộc tình, tiến hành Update thôi.

Tắt phiên bản MariaDB đang chạy

Stop MySQL đang chạy bằng lệnh sau:

#Centos 7
systemctl stop mysql
#Centos 6
service mysql stop

Kiểm tra chính xác xem MySQL đã tắt chưa:

#Centos 7
systemctl status mysql
#Centos 6
service mysql status

Kết quả như sau bạn đã tắt được MySQL

mysql.service - LSB: start and stop MariaDB
Loaded: loaded (/etc/rc.d/init.d/mysql; bad; vendor preset: disabled)
Active: inactive (dead) since Sun 2019-12-29 20:29:26 +07; 1s ago
Docs: man:systemd-sysv-generator(8)
Process: 3296 ExecStop=/etc/rc.d/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 839 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)

Backup dữ liệu

Để an toàn, bạn hãy backup dữ liệu đang có bằng lệnh sau:

cp -r /var/lib/mysql /var/lib/mysqlbackup

Xoá phiên bản MariaDB đang chạy

Bạn cần xoá phiên bản MariaDB đang chạy để nhường chỗ cho bản cập nhật sau

yum remove MariaDB-server

Tiến hành cập nhật MariaDB cho HocVPS Script

Ok, bây giờ bạn có thể cập nhật MariaDB. Tại SFTP truy cập  /etc/yum.repos.d  tìm file   MariaDB.repo sửa nội dung file này thành:

# MariaDB 10.4 CentOS repository list - created 2017-04-12 03:14 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=http://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Lưu ý rằng bạn chỉ sửa version mà mình tô đỏ ở trên thôi nhé.

Tiến hành  cập nhật bằng lệnh sau:

yum install MariaDB-server MariaDB-client

Nhấn Y để đồng ý tải về và cài đặt.

Chỉnh sửa file /etc/my.cnf tìm dòng  87 và xoá nó

innodb_support_xa=1

Khi quá trình cài đặt hoàn tất, hãy bật MariaDB để khởi động dịch vụ bằng lệnh:

systemctl enable mariadb
systemctl start mariadb

Kiểm tra lại MariaDB bằng lệnh

mysql -u admin -p

Nếu như bạn nhận được kết quả này là bạn đã thành công:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.7-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statemen.