How to temporarily disable Foreign Key Checks or Constraints in MySQL

While importing a database that has tables with foreign keys defined we get to see error “#1452 – Cannot add or update a child row: a foreign key constraint fails“.

Even while trying to delete some tables from such a database, we come across situation where we face foreign key constraint error: “#1217 – Cannot delete or update a parent row: a foreign key constraint fails

To avoid such errors first disable the foreign key checks, then do your job of importing the database or deleting the table and finally enable the foreign key checks.

Continue reading »

WinSCP: How to view the hidden files like .htaccess

WinSCP comes with a configuration setting that allows you to show or hide the hidden files . To view the hidden files, activate the setting by going to:

Options >> Preferences >> Panels

Select the “Show hidden files”  option under the common settings and click the “OK” button.

Continue reading »

How to restore mysql database from command line

We need to import database on local machine when setting up a live website locally or when we are transferring hosting from one service provider to another. Let’s see how we can import MySQL database dump from command line

Assuming that we have created the database say ‘mynewdb’ in which we have to import.

Run the following command

$ mysql -u username -ppassword mynewdb < dbbackupfile.sql

Continue reading »

How to backup mysql database from command line

It is necessary to take database backups at regular intervals to prevent loss of data. In this article we will see how we can backup mysql database using command line.

‘mysqldump’ command can be used to create backup of MySQL database as follows:

$ mysqldump -u username -ppassword dbname > dbname.sql

The above command assumes that you are running the ‘mysqldump’ command on the same server on which MySQL is installed.

Continue reading »

SOAP-ERROR: Parsing WSDL: Couldn’t load from … : failed to load external entity …

I had written some code using Magento API, it worked fine on my local machine but when I transferred the same code to my linux server I got the following error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://mydomain.com/api/soap/?wsdl=1' : failed to load external entity "http://mydomain.com/api/soap/?wsdl=1"

When I opened the URL ‘http://mydomain.com/api/soap/?wsdl=1’ directlty in my browser, it displayed the wsdl file as expected.

Continue reading »

Working with MySql Indexes

MySql

Indexes are needed to improve the performance of SELECT queries. They can be defined with table creation and also created after table creation with CREATE INDEX and ALTER TABLE statements. If during optimization you find that an index is not useful then you can DROP them using DROP INDEX or ALTER TABLE statements.

Continue reading »

Understanding MySql Indexes and their types

MySql

Indexes are needed to improve the performance of SELECT queries. Indexes in Mysql are just like the indexes available in books. Without indexes if we have to look for a topic in a book then we will have to go through each page content but luckily we have an index, we find the page number from the index and then open that page directly. Similarly in MySql if we have to find row(s) have a particular column value then without index on that column MySql will have to scan each row of the table to find the matching rows.

It is highly recommended that you create indices on columns of a table from which you often query the data.

Continue reading »

#1452 – Cannot add or update a child row: a foreign key constraint fails…

MySql

Are you trying to import a MySql dump file and getting the following error: “#1452 – Cannot add or update a child row: a foreign key constraint fails”? Its because of the foreign key validation checks.

You can run the following statement to get detailed error information:

SHOW ENGINE INNODB STATUS;

Continue reading »

How to get low stock product notifications in Magento?

Magento

Magento provides RSS feed for low inventory alerts. Lets us discuss how to subscribe to the feed.

First we need to set up the inventory level of a product at which it will be considered as low stock.

  1. Login to admin and navigate to System >> Configuration
  2. Scroll down to the Catalog tab and click the Inventory section to open it. Now expand the ‘Product Stock Options’ section.
  3. Set Manage Stock as ‘Yes’ and add a value for ‘Notify for Quantity Below’, save the configuration. Note that you do not set ‘Notify for Quantity Below’ as 0 as it disables the RSS feed.

Continue reading »

JSON – An Overview

JSON

JSON stands for JavaScript Object Notation. It is a format for storing and exchanging data. It is based on a subset of the JavaScript Programming Language.

The file type for JSON files is “.json” and MIME type for JSON text is “application/json“.

Here are the characteristics of JSON:

  1. It is a lightweight data-interchange format.
  2. It is easy for humans to understand.
  3. It uses Javascript format but it is a text which makes it is completly language independent as text can be read and parsed by any programmng language.

Continue reading »

Back to top