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

719

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

<config>
<global>
    <install>
        <date><![CDATA[Thu, 20 Dec 2012 04:20:32 +0000]]></date>
    </install>
    <crypt>
        <key><![CDATA[1dba174377df948cc045234de2d2d959]]></key>
    </crypt>
    <disable_local_modules>false</disable_local_modules>
    <resources>
        <db>
            <table_prefix><![CDATA[]]></table_prefix>
        </db>
        <default_setup>
            <connection>
                <host><![CDATA[localhost]]></host>
                <username><![CDATA[root]]></username>
                <password><![CDATA[]]></password>

                <dbname><![CDATA[btrweb]]></dbname>
                <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                <model><![CDATA[mysql4]]></model>
                <type><![CDATA[pdo_mysql]]></type>
                <pdoType><![CDATA[]]></pdoType>
                <active>1</active>
            </connection>
        </default_setup>
    </resources>
    <session_save><![CDATA[files]]></session_save>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <frontName><![CDATA[admin]]></frontName>
            </args>
        </adminhtml>
    </routers>
</admin>

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.

249

Answer

Solution:

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

Source

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.