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:
-
Upload your MySQL dump file to your server:
- You can use SFTP (Secure File Transfer Protocol) to upload your
.sqldump 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.
- You can use SFTP (Secure File Transfer Protocol) to upload your
-
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
-
Import the database:
- Once you're connected to your server via SSH, navigate to the directory where you uploaded your
.sqlfile. - Use the
mysqlcommand 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.
- Once you're connected to your server via SSH, navigate to the directory where you uploaded your
-
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;
- 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:
-
Clean up:
- After verifying the import, you can remove the
.sqldump file from your server if you wish to keep things clean.
- After verifying the import, you can remove the
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.