Importing a .sql.gz database into a new database

Support/Development for MySQL, MariaDB, and other database systems
David23
Forum User
Forum User
Posts: 17
Joined: Wed Aug 14, 2013 7:49 am
Location: UK

Importing a .sql.gz database into a new database

Unread post by David23 »

Hello there,

I am new to this forum so please I am trying to import a WordPress database dump into a new database as a client is migrating their domain to us. I have the database dump vkjekule_srfc.sql.gz and I have created a new database for it to import into and have the following details from the wp-config.php file:

/** The name of the database for WordPress */
define('DB_NAME', 'vkjekule_srfc');

/** MySQL database username */
define('DB_USER', 'vkjekule_wp');

But I am not sure how to import this into the database that I created on our server:
salisburyrfc_wp
DB user = salrfc

Please could someone help me with the command that I need to import the database across. I think that is all the details but if you require anymore then I will provide these for you.

Many thanks,
David
Last edited by David23 on Wed Dec 18, 2013 8:27 am, edited 2 times in total.
prupert
Forum Regular
Forum Regular
Posts: 573
Joined: Tue Aug 01, 2006 2:45 pm
Location: Netherlands

Re: Importing a .sql.gz database into a new database

Unread post by prupert »

You can do it from the shell:

Code: Select all

# First extract the gzipped file
gunzip vkjekule_srfc.sql.gz

# Then import the SQL dumpfile into your database 'salisburyrfc_wp'
mysql --user=salrfc --password=S4lrfc salisburyrfc_wp < vkjekule_srfc.sql
If you are not comfortable with the command-line interface you can use the import database functionality of a GUI client or web interface such as phpMyAdmin that is usually provided with your control panel.

Tip: never post passwords publicly.
Lemonbit Internet Dedicated Server Management
David23
Forum User
Forum User
Posts: 17
Joined: Wed Aug 14, 2013 7:49 am
Location: UK

Re: Importing a .sql.gz database into a new database

Unread post by David23 »

Thank you for this Prupert, will have a go now! Sorry they are only fake user names and passwords but I just named them so that everyone could understand the scenario and then I can replace them with the real details when the importing occurs, but thank you for the advice.
David23
Forum User
Forum User
Posts: 17
Joined: Wed Aug 14, 2013 7:49 am
Location: UK

Re: Importing a .sql.gz database into a new database

Unread post by David23 »

Ok I am still a bit confused.

1. Do I have to be in a certain directory to run this command?

2. I am logged into SSH as root and need to run this command: mysql –u myuser -pmypassword salisburyrfc_wp < filename.sql but the file is root/myname/myfile.sql so do I have to do a path to the file before the filename.sql section of the command?

Many thanks,
David
David23
Forum User
Forum User
Posts: 17
Joined: Wed Aug 14, 2013 7:49 am
Location: UK

Re: Importing a .sql.gz database into a new database

Unread post by David23 »

I think I have worked out how to execute the command. Now I have run it I am getting the following error:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1

So I tried importing without the first line but that still gave me another error. I am sure I just need to take a step back and relax and then look at this again from another angle. But please if anyone can help then that would be much appreciated.

Many thanks,
David
Post Reply