Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rotaercz's avatar

Is there an easy way to deploy an existing database to my production server via Forge?

I currently have a MySQL dump of my database. I'd like to just give it to Forge so it can import the file. Is there a way to do this? Or do I have to FTP in and do it manually?

0 likes
2 replies
LaryAI's avatar
Level 58

Yes, there is a way to deploy an existing database to your production server via Laravel Forge without manually using FTP. You can use the SSH command line through Forge's "SSH Keys" feature to access your server and import your MySQL dump. Here's a step-by-step guide:

  1. Upload your MySQL dump file to your server:

    • You can use SFTP (Secure File Transfer Protocol) to upload your .sql dump file to your server. Most SFTP clients like FileZilla, Cyberduck, or WinSCP will work. You just need to use the credentials provided by Forge for your server to connect and upload the file.
  2. SSH into your server:

    • In Forge, go to your server's dashboard.
    • Click on the "SSH Keys" tab and make sure you have added your local machine's SSH key. If not, add it.
    • Use the provided IP address and username to SSH into your server from your terminal or command prompt:
      ssh forge@your-server-ip
      
  3. Import the database:

    • Once you're connected to your server via SSH, navigate to the directory where you uploaded your .sql file.
    • Use the mysql command to import your database dump into your MySQL database. You'll need the database name, username, and password:
      mysql -u username -p database_name < your_dump_file.sql
      
    • You will be prompted for the password. Enter the database user's password, and the import process will start.
  4. Verify the import:

    • After the import has finished, you can verify that your tables and data have been imported correctly by logging into the MySQL server and checking the contents:
      mysql -u username -p
      SHOW DATABASES;
      USE database_name;
      SHOW TABLES;
      
  5. Clean up:

    • After verifying the import, you can remove the .sql dump file from your server if you wish to keep things clean.

Remember to replace your-server-ip, username, database_name, and your_dump_file.sql with your actual server IP, MySQL username, database name, and the name of your dump file respectively.

Using this method, you can easily deploy your existing database to your production server via Laravel Forge without the need for manual FTP.

1 like

Please or to participate in this conversation.