Di halaman ini, Anda mengonfirmasi bahwa tugas migrasi telah memigrasikan data dari instance database sumber ke instance database Cloud SQL tujuan dengan benar.
Minimal, pastikan instance database dan tabelnya ada di
instance Cloud SQL. Anda juga dapat memverifikasi jumlah baris tabel atau konten
yang tepat.
Langkah-langkah berikut menunjukkan contoh minimal:
Jalankan perintah SQL untuk memverifikasi migrasi. Contoh:
Pada perintah postgres, masukkan \list untuk mencantumkan database dan memverifikasi bahwa Anda melihat instance database sumber.
Pada perintah postgres, masukkan \connect SOURCE_DB_NAME, dan masukkan sandi saat diminta, untuk terhubung ke instance database dan melihat tabel yang terkait dengan instance tersebut. Nama dari perintah berubah dari postgres menjadi SOURCE_DB_NAME.
Pada perintah SOURCE_DB_NAME, masukkan \dt untuk melihat tabel instance ini.
Pada perintah SOURCE_DB_NAME, masukkan GRANT cloudsqlexternalsync to USER; karena Anda ingin memberikan izin kepada pengguna ini agar dapat mengakses data dalam tabel instance ini. Selain itu, ganti USER dengan nama pengguna yang Anda gunakan untuk terhubung ke instance database tujuan.
Pada perintah SOURCE_DB_NAME, masukkan SELECT * from TABLE_NAME; untuk melihat informasi yang direplikasi dari tabel dalam instance database sumber Anda.
Pastikan Anda melihat informasi yang benar dalam tabel.
Pastikan batasan seperti kunci utama, kunci asing, dan indeks dimigrasikan ke instance database Cloud SQL tujuan dengan benar.
Jika semua yang Anda periksa sesuai dengan yang Anda harapkan, berarti Database Migration Service telah memigrasikan data dengan benar.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-05 UTC."],[[["\u003cp\u003eThis guide helps verify that a database migration job has correctly transferred data from a source database to a destination Cloud SQL instance.\u003c/p\u003e\n"],["\u003cp\u003eThe basic verification process includes confirming the existence of the migrated database instance and its tables in the Cloud SQL instance.\u003c/p\u003e\n"],["\u003cp\u003eYou can also run SQL commands through the Cloud Shell to check the row counts or exact contents of migrated tables.\u003c/p\u003e\n"],["\u003cp\u003eTo check data integrity, one must grant specific user permissions to access table data via the cloud shell.\u003c/p\u003e\n"],["\u003cp\u003eChecking constraints such as primary keys, foreign keys, and indexes should also be verified in the destination database.\u003c/p\u003e\n"]]],[],null,["# Verify a migration\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n[MySQL](/database-migration/docs/mysql/verify-migration \"View this page for the MySQL version of Database Migration Service.\") \\| PostgreSQL \\| [PostgreSQL to AlloyDB](/database-migration/docs/postgresql-to-alloydb/verify-migration \"View this page for the PostgreSQL to AlloyDB version of Database Migration Service.\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nVerifying a migration\n---------------------\n\nIn this page, you confirm that the migration job migrated data from your source database instance to the destination Cloud SQL database instance correctly.\n\n\u003cbr /\u003e\n\nAt a minimum, verify that the database instance and its tables exist in the\nCloud SQL instance. You can also verify the tables' row counts or exact\ncontents.\n\n\nThe following steps show a minimal example:\n\n1. Go to the [SQL Instances page](https://console.cloud.google.com/sql) in the Google Cloud console.\n2. Click the read replica entry of your migration job.\n3. Click the **Activate Cloud Shell** icon that appears in the upper-right region of the page.\n4. At the Cloud Shell prompt, press **Enter**.\n5. Optional: If an **Authorize Cloud Shell** dialog box appears, then click **Authorize**.\n6. At the **Enter password** prompt, enter the password that you either provided or that Database Migration Service generated for you in [Define and create the destination Cloud SQL instance](/database-migration/docs/mysql/create-migration-job#dest).\n7. Run SQL commands to verify the migration. For example:\n 1. At the **postgres** prompt, enter `\\list` to list the databases and verify that you see your source database instance.\n 2. At the **postgres** prompt, enter `\\connect `\u003cvar translate=\"no\"\u003eSOURCE_DB_NAME\u003c/var\u003e, and enter the password when prompted, to connect to the database instance and see the tables associated with the instance. The name of the prompt changes from `postgres` to \u003cvar translate=\"no\"\u003eSOURCE_DB_NAME\u003c/var\u003e.\n 3. At the \u003cvar translate=\"no\"\u003eSOURCE_DB_NAME\u003c/var\u003e prompt, enter `\\dt` to see the tables of this instance.\n 4. At the \u003cvar translate=\"no\"\u003eSOURCE_DB_NAME\u003c/var\u003e prompt, enter `GRANT cloudsqlexternalsync to `\u003cvar translate=\"no\"\u003eUSER\u003c/var\u003e`;` because you want to give this user permission to access the data in the tables of this instance. Also, replace \u003cvar translate=\"no\"\u003eUSER\u003c/var\u003e with the name of the user you used to connect to the destination database instance.\n 5. At the \u003cvar translate=\"no\"\u003eSOURCE_DB_NAME\u003c/var\u003e prompt, enter `SELECT * from `\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e`;` to see the information that's replicated from a table in your source database instance.\n 6. Verify that you see the correct information in the table.\n8. Verify that constraints such as primary keys, foreign keys, and indexes were migrated to the destination Cloud SQL database instance correctly.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nIf everything you check is as you expect, then Database Migration Service has migrated the data correctly."]]