Tóm lại, tôi đã di chuyển thành công từ MariaDB 10. 4. 11 đến MySQL 5. 7. 38. Lý do là để kiểm tra công cụ InnoDB của phiên bản cụ thể, cụ thể là 5. 7. 38
Trên thực tế, nó khá dễ dàng với bitnami lampstack. Hơn nữa, với bitnami, bạn có thể dễ dàng định cấu hình để chạy cả MariaDB và MySQL [1] [đồng thời trên các cổng khác nhau hoặc từng cái một trên cùng một cổng mặc định] và kiểm soát chúng thông qua trình quản lý [hoặc thông qua các dịch vụ systemd]
Nỗ lực đầu tiên của tôi là tìm phiên bản MySQL gần nhất trong nhật ký thay đổi gói bitnami lampstack và tải xuống gói này, nhưng nó bị thiếu trên web [Phiên bản trên 7. 1. 33 [MySQL 5. 7. 28] và dưới 7. 2. 24 [chuyển sang MySQL 8]]
Đặt cược tốt nhất tiếp theo của tôi là lấy bất kỳ gói bitnami nào có sẵn [7. 2. 26] và chỉ để trao đổi gói MySQL đã cài đặt. [Xin lỗi, không có wget ở đây vì liên kết được tiết lộ theo bộ đếm thời gian. Vui lòng cập nhật nếu bạn tìm thấy tài liệu lưu trữ của họ]
Chạy trình cài đặt trước để có danh sách đầy đủ các tùy chọn [chọn mô-đun sẽ cài đặt]
./bitnami-lampstack-7.2.26-0-linux-x64-installer.run --help
và để cài đặt với các cài đặt bị ghi đè [tôi thích cài đặt nó với tư cách người dùng hơn, vì vậy không có sudo ở đây]
./bitnami-lampstack-7.2.26-0-linux-x64-installer.run --prefix /opt/bitnami/lampstack-7.2.26.0 --disable-components varnish,zendframework,symfony,codeigniter,cakephp,smarty,laravel --base_password testpass --apache_server_port 9955 --apache_server_ssl_port 9943 --mysql_port 3309 --mode unattended
Tại thời điểm này, bạn sẽ có một ngăn xếp LAMP đang hoạt động với các dịch vụ đang chạy trên các cổng đã chọn. Đáng buồn thay, nhưng bitnami không có cờ để tắt ứng dụng ngay từ đầu, vì vậy chúng tôi cần thực hiện việc đó theo cách thủ công
$ cd /opt/bitnami/lampstack-7.2.26.0 && ./ctlscript.sh status && ./ctlscript.sh stop
apache already running
mysql already running
Syntax OK
/opt/bitnami/lampstack-7.2.26.0/apache2/scripts/ctl.sh : httpd stopped
/opt/bitnami/lampstack-7.2.26.0/mysql/scripts/ctl.sh : mysql stopped
Cài đặt phiên bản MySQL đã chọn
Như bạn đã nhận thấy, sau đó các mô-đun lampstack được điều khiển thông qua các tập lệnh ctl trong thư mục 'tập lệnh' của chúng. Vì vậy, phần quan trọng nhất là có các tập lệnh đó trong phần cài đặt tùy chỉnh của MySQL
$ mv mysql mysql_original
$ mkdir mysql && mkdir mysql/{tmp,run,data}
$ cp -r mysql_original/scripts mysql/
$ cp mysql_original/my.cnf mysql ##it should be adapted to your previous configuration, but keep defined directory variables
$ wget //downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
$ tar -xzf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C mysql --strip-components 1 ##untar archive contents into mysql skipping root directory
$ ln -s /opt/bitnami/lampstack-7.2.26.0/mysql/bin/mysqld /opt/bitnami/lampstack-7.2.26.0/mysql/bin/mysqld.bin ##or fix mysql ctl.sh to use mysqld instead of mysqld.bin
Bây giờ bạn có hai lựa chọn. để sao chép 'dữ liệu' từ bản cài đặt MariaDB cũ hoặc khởi tạo DB mới rồi nhập kết xuất. Cái đầu tiên không đáng tin cậy, vì vậy tôi thích cái thứ hai hơn
Tùy chọn 1 Di chuyển 'dữ liệu' MariaDB
NB. Sao lưu thư mục 'dữ liệu' và/hoặc tạo kết xuất DB [bằng cách bỏ qua tùy chọn 1 và chuyển sang tùy chọn 2]
$ cp -R old_data/ /opt/bitnami/lampstack-7.2.26.0/mysql/
$ ./opt/bitnami/lampstack-7.2.26.0/ctlscript.sh start mysql
Chắc chắn bạn sẽ gặp lỗi này nếu bạn làm theo tùy chọn này và đang hạ cấp
InnoDB: Unsupported redo log format. The redo log was created with MariaDB 10.2.44. Please follow the instructions at //dev.mysql.com/doc/refman/5.7/en/upgrading-downgrading.html
NB. Hành động có thể gây hại Một giải pháp thay thế là xóa các tệp ib_logfile* rồi bắt đầu lại dịch vụ
Sau đó, bạn sẽ gặp phải một loạt lỗi, nhưng db sẽ hoạt động
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to //dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery
và
[ERROR] InnoDB: Page [page id: space=0, page number=734] log sequence number 3261161573 is in the future! Current system log sequence number 3221898782.
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to //dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
Sau đó, bạn cần nâng cấp DB bằng cách gọi mysql_upgrade. Hãy tạo ctl_upgrade. kịch bản sh cho điều đó
Tùy chọn 2 Kết xuất và nhập DB
Tôi sẽ không đi sâu ở đây, vì quá trình này khá đơn giản. đổ
$ vi /opt/bitnami/mysqldump.sh
#!/bin/sh
## Dump DB with no DB name in two rows:
## 1. dump structure with routines and no data
## 2. dump only data in ansi mode
## I avoid dumping with auto creating database to avoid collisions with existing databases on import.
MYSQL_BIN=mysqldump ##note, here i use old mysql binary available globally
PASSWORD=
HOST=$1
USER=root
DATABASE=$2
IGNORED_TABLES_STRING='' #if you want to skip some tables from dumping
now="$[date +'%d_%m_%Y_%H_%M']"
filename="${DATABASE}_db_backup_$now.sql"
backupfolder="./mysqldump"
logfile="$backupfolder/"backup_log_"$[date +'%Y_%m']".txt
echo "Dump structure started at $[date +'%d-%m-%Y %H:%M:%S']" >> "$logfile"
$MYSQL_BIN --host=${HOST} --user=${USER} --password=${PASSWORD} --no-create-db ${DATABASE} --single-transaction --no-data --routines --log-error $logfile > $backupfolder/${DB_FILE}
echo "Dump structure finished at $[date +'%d-%m-%Y %H:%M:%S']" >> "$logfile"
echo "Dumping contents"
##note dumped db will be in ansi mode, for better [compatibility][5]
$MYSQL_BIN --compatible=ansi --host=${HOST} --user=${USER} --password=${PASSWORD} --no-create-db ${DATABASE} --no-create-info --skip-triggers ${IGNORED_TABLES_STRING} --log-error $logfile >> $backupfolder/${DB_FILE}
$ cd /opt/bitnami && mkdir mysqldump && sh mysqldump.sh localhost db_to_dump
## stop old lampp services
$ ./opt/lampp/ctlscript.sh stop
Nhập vào DB mới
./bitnami-lampstack-7.2.26-0-linux-x64-installer.run --prefix /opt/bitnami/lampstack-7.2.26.0 --disable-components varnish,zendframework,symfony,codeigniter,cakephp,smarty,laravel --base_password testpass --apache_server_port 9955 --apache_server_ssl_port 9943 --mysql_port 3309 --mode unattended
0Kiểm tra nhật ký trong thư mục 'dữ liệu'. Quá trình di chuyển đã hoàn tất
Không bắt buộc. Cài đặt MariaDB vào trình quản lý lampstack
Tôi đã chọn MariaDB có cùng phiên bản InnoDB
./bitnami-lampstack-7.2.26-0-linux-x64-installer.run --prefix /opt/bitnami/lampstack-7.2.26.0 --disable-components varnish,zendframework,symfony,codeigniter,cakephp,smarty,laravel --base_password testpass --apache_server_port 9955 --apache_server_ssl_port 9943 --mysql_port 3309 --mode unattended
1Không bắt buộc. dịch vụ systemd cho ống khói
./bitnami-lampstack-7.2.26-0-linux-x64-installer.run --prefix /opt/bitnami/lampstack-7.2.26.0 --disable-components varnish,zendframework,symfony,codeigniter,cakephp,smarty,laravel --base_password testpass --apache_server_port 9955 --apache_server_ssl_port 9943 --mysql_port 3309 --mode unattended
2[1]. Tôi tin rằng điều đó có thể xảy ra với gói xampp linux, nhưng ngay từ cái nhìn đầu tiên, tôi đã thấy cấu hình của nó lộn xộn vì tất cả các mô-đun đều được nối với nhau