将Drupal网站迁移至Google Cloud Platform的技术求助
Hey John, let's walk through how to get your old Drupal database imported into that Bitnami Drupal instance on GCP—this is totally doable with the tools you already have. Here's a step-by-step breakdown tailored to your setup:
1. Prep Your Database Files First
- If you have a
.GZcompressed file, unzip it to get the raw.SQLfile. You can do this locally with tools like 7-Zip, or if the file's already on your GCP server, run this command in the SSH terminal:gzip -d your-old-db.sql.gz - Quick check: Open the
.SQLfile and make sure it starts with a character set declaration likeSET NAMES utf8mb4;—Drupal relies on this for proper character handling, so match it to your target database's charset.
2. Grab Bitnami Drupal's Database Credentials
Bitnami stores database info in a few easy-to-find spots:
- Log into your GCP server via SSH, then run this to get all credentials at once:
Look for lines withcat /opt/bitnami/scripts/bitnami_credentialsdatabase user,database password, anddatabase name(usuallybitnami_drupalby default). - Alternatively, check Drupal's core config file to confirm:
Scan for thecat /opt/bitnami/drupal/sites/default/settings.php$databasesarray—it'll spell out exactly which database Drupal is using.
3. Import via PhpMyAdmin (Your Already Configured Setup)
Since you've got SSH access set up for PhpMyAdmin, this is straightforward:
- Connect to PhpMyAdmin through your SSH tunnel, then log in using the Bitnami database credentials you found.
- Select the target database (e.g.,
bitnami_drupal) from the left sidebar. - Click the Import tab at the top:
- Choose your
.SQLfile using the file picker. - Set the Character set to
utf8mb4(critical for Drupal's content). - If your old database used a table prefix (like
drupal_) that's different from Bitnami's default (bitnami_), use the "Find and replace" section to swap them out before importing. - Hit Execute and wait for the process to finish. If you get "table already exists" errors, just delete all existing tables in the target database first (don't delete the database itself!).
- Choose your
4. Faster Alternative: Command-Line Import (Great for Large Files)
PhpMyAdmin can time out with huge SQL files—so if your backup is big, use the command line instead:
- Upload your
.SQL(or.GZ) file to your GCP server's/tmpdirectory (use FTP orscpfrom your local machine). - SSH into the server, then if it's a
.GZfile, unzip it first (like step 1 above). - Run this import command, replacing placeholders with your actual credentials (or use the shortcut below to auto-pull Bitnami's credentials):
This command grabs the password directly from Bitnami's credential file, so you don't have to type it manually.mysql -u bn_drupal -p$(cat /opt/bitnami/scripts/bitnami_credentials | grep -oP 'password: \K.*') bitnami_drupal < /tmp/your-old-db.sql
5. Post-Import Checks
- Fire up your Bitnami Drupal site and navigate around to confirm old content loads correctly.
- If you get a database connection error, double-check the
settings.phpfile to ensure the database name, user, and password match what you used for the import. - If some content is missing, review the import logs (either in PhpMyAdmin or the command line output) for errors—common issues include truncated files or mismatched character sets.
内容的提问来源于stack exchange,提问作者JohnGIS
相关产品推荐
相关产品推荐

