php - How to load already built in Magento project to localhost with database?


I have to customize some of the things in already built in magento project. I copied the source file and pasted in htdocs folder and loaded the sql file in database. Modified host,username,password,dbname in the xml file which is situated in app/etc/local.xml folder. Which is as follows

        <date><![CDATA[Thu, 20 Dec 2012 04:20:32 +0000]]></date>

                <initStatements><![CDATA[SET NAMES utf8]]></initStatements>

Now when I load the file as localhost/btrweb(projectname) it is throwing an error like

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'directory_country' already exists

Could you please help me out from this.

Thanks in advance.




First of all I should say the best way is using a versioning system like Git! In this way you can simply clone your repositories anywhere you want.

In your case I think your problem is due to the way you moved (dumped/imported) your DB in the localhost DB. In general in Magento each module (that has interactions with DB) holds a sql folder with file(s) inside that track DB changes in the history of that module. All files in this folder run sequentially (after running each file magento adds its version to a table (named: core_resource); in this way Magento knows which file was already run and avoids re-running it. In your case the directory module of Magento -> (you can find it in: core/Mage/Directory) is failing to run one of these scripts and therefore throwing that error. You can whether try to restore your DB (highly recommended) or try this way:DELETE * FROM core_resource WHERE code = "directory_setup" (remove all the Magento cache). In first reload of any page Magento will automatically run all the scripts in that sql folder again and this might fix your problem.

P.S: Don't forget you need to update core_config_data table as well, with secure_url and unsecure_url to point to your alias in localhost.

People are also looking for solutions to the problem: mysql - PHP Login page with Indexxeddb


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.