How to importing sql file (database) into website

Hi, I am really struggling to import database date from a sql backup file. I am using a Linode having set it up with Cyberpanel from the Linode marketplace. I am a newbie and I can’t figure out how mysql / Mariadb, Cyberpanel, my domain name (and hence website files) all link together.
Using phpMyAdmin is not an option as media files (images) are included in the data I need to import which exceeds the phpMyAdmin import limit.

Upload your sql file (backup file) to your website directory.

Login to ssh and run this command

mysql -u YOURDATABASE_USER -p YOURDATABASENAME < /home/DOMAIN_NAME/YOURSQLFILE.sql

In the above code, replace all the capital letters mentioned to your relevant input.
YOURDATABASE_USER is the database user name.
YOURDATABASENAME is the database name where you want the sql file to be imported.
/home/DOMAIN_NAME/YOURSQLFILE.sql refers to the full path where you have uploaded your sql backup file

If any doubt, you can let me know.

Run this command and it will ask for password of your database, type it and press enter (you wont see anything when you type password)
After that your ssh program will execute the import function in background… It will not display anything on your ssh screen… Wait till you see new command acceptance line as you see usually.

Hello @die2mrw007 and many thanks for responding - it is greatly appreciated.
And oh my goodness! I have been omitting the ‘<’ character from my command. I couldn’t see reference to it in any official documentation (such as here) and so presumed it was indicating something like ‘insert your filename here’. After inserting that character the behaviour was as you stated and I can now see loads of tables and data into the target database via phpMyAdmin.

Thanks again.

1 Like