MySQL

MySQL is a widely used relational database system for managing structured data. With Kinsta’s Database Hosting, you can easily add a new MySQL database from the dashboard, click Databases > Add database and select the required options. 

If you have an existing database locally or with another hosting provider, you can import the MySQL database into Kinsta’s Database Hosting using a third-party database tool or the Command Line Interface (CLI). Note: To import a database, you must create a new database in MyKinsta first.

Import a MySQL Database Using a Database Tool

There are many database tools you can use to connect and manage your database; we have step-by-step instructions for TablePlus, as this tool allows you to manage all the database types you can host on Kinsta.

You can use any database client or tool that supports your database type. While some specifics, like navigation and field names, may vary between database tools, the fundamental concepts are the same.

Import a MySQL Database Using the Command Line Interface (CLI)

You can use the command line interface (CLI) to import your MySQL database into Kinsta. The installation of the database server and commands vary for each database type. This article is specific to MySQL. For other database types, see:

Install MySQL

If you do not yet have MySQL installed on your local machine, you’ll need to install it to connect to your database. Depending on your operating system, you can install MySQL in the following ways.

Windows

Download and install MySQL Community Server (GUI program).

MacOS

Choose one of the following options for installing MySQL on MacOS:

Debian-based Linux (Debian, Ubuntu, Mint, etc.)

Use the official MySQL APT repository and install the mysql-client package.

RedHat-based Linux (RedHat Fedora, CentOS, etc.)

Use the official MySQL Yum repository and install the mysql-client package.

Kinsta Database Credentials

You can find your database credentials under External connections on the database Overview page.

Import a MySQL Database

Use the following command to export the database, replacing EXTERNAL_HOSTNAME, USERNAME, PORT, and DATABASE_NAME with the information from your database’s External connections. Replace export.sql with the path and name of the database you want to import:

mysql -h EXTERNAL_HOSTNAME -u USERNAME -P PORT -p DATABASE_NAME < export.sql

When prompted, enter the database password.

No output will be produced unless there are errors, which will be printed to the command line. To verify a successful import, you can use SHOW TABLES; or a similar command to review the data in your database.

Export a MySQL Database

Use the following command to export the database, replacing EXTERNAL_HOSTNAME, USERNAME, PORT, and DATABASE_NAME with the information from your database’s External connections. Replace export.sql with the path and file name of the database you want to export:

mysqldump --no-tablespaces -h EXTERNAL_HOSTNAME -u USERNAME -P PORT -p DATABASE_NAME > export.sql

When prompted, enter the database password.

Once the export is complete, your database file (e.g. export.sql) will be available at the path you specified in the mysqldump command. You can open the file with a plain text editor (e.g. TextEdit, Notepad++, Sublime Text, etc.) or a database tool like TablePlus to review the exported data.