How to import a MySQL database using debug access

4 min read Updated 1 week ago

How to import a MySQL database using debug access

Debug access allows you to temporarily connect to your MySQL service from external tools to import databases, run maintenance tasks, or perform troubleshooting. This feature creates a secure external connection that automatically expires after 6 hours.

Prerequisites

  • You must have an active MySQL service in your application

  • The MySQL service must be in "active" status

  • You need database administration tools like MySQL Workbench, phpMyAdmin, or command-line mysql client

Enabling debug access

  1. Navigate to your application's overview page

  2. Find your MySQL service in the services list

  3. Click the three-dot menu (⋮) next to your MySQL service

  4. Select "Enable debug access" from the dropdown menu

Note: Debug access is not available for worker services. Only database, cache, and storage services support debug access.

Obtaining connection details

Once debug access is enabled, you'll see a "Debug session active" indicator next to your service. To view the connection details:

  1. Click the three-dot menu (⋮) next to your MySQL service

  2. Select "Debug access" from the dropdown menu

  3. A modal will appear with the following connection information:

    • Host: External IP address

    • Port: External port number (randomly assigned between 30000-32767)

    • Username: Your MySQL username (typically "dbuser")

    • Password: Your MySQL password

    • Connection URL: Complete connection string in format mysql://username:password@host:port/database

Important: Each connection detail has a copy button for easy copying. The password field has a visibility toggle for security.

Importing your database

Using command line (mysql client)

  1. Copy the connection details from the debug access modal

  2. Export your existing database to a SQL file:

    mysqldump -u [source_username] -p [source_database] > database_backup.sql

  3. Import to your service using the debug access credentials:

    mysql -h [debug_host] -P [debug_port] -u [username] -p [database_name] < database_backup.sql

Using MySQL Workbench

  1. Create a new connection in MySQL Workbench

  2. Enter the connection details:

    • Hostname: Use the Host value from debug access

    • Port: Use the Port value from debug access

    • Username: Use the Username from debug access

    • Password: Use the Password from debug access

  3. Test the connection and connect

  4. Use the Data Import/Restore feature to import your SQL file

Using phpMyAdmin or other tools

  1. Configure your tool with the debug access connection details

  2. Use the tool's import functionality to upload your SQL file

  3. Select the target database and run the import

Security and time limits

  • Debug access automatically expires after 6 hours

  • The remaining time is displayed in the debug access modal (e.g., "5h 23m remaining")

  • External access is restricted to only your MySQL service pods through network policies

  • You can manually disable debug access at any time

Disabling debug access

To manually disable debug access before it expires:

  1. Click the three-dot menu (⋮) next to your MySQL service

  2. Select "Disable debug access" from the dropdown menu

  3. The external connection will be immediately terminated

Note: All debug sessions are automatically cleaned up every 2 hours, so expired sessions will be removed automatically.

Troubleshooting

Cannot connect to MySQL service

  • Verify the service status is "active"

  • Check that debug access is enabled and not expired

  • Ensure your firewall allows outbound connections on the specified port

  • Try copying the connection details again in case of typos

Import fails or times out

  • For large databases, consider importing in smaller chunks

  • Check the service logs for any error messages

  • Verify you have sufficient storage space allocated to your MySQL service

  • Ensure your SQL file is compatible with your MySQL version (8.0 or 5.7)

Debug access button not available

  • Debug access is only available for database, cache, and storage services

  • Worker services do not support debug access

  • Ensure the service is not in a transitional state (starting, stopping, deploying)

Best practices

  • Always disable debug access when finished to maintain security

  • Use debug access during maintenance windows when possible

  • Test imports with small sample data first

  • Keep backups of your original data before importing

  • Monitor the remaining time to avoid connection timeouts during long imports