Archive for the ‘Web Development’ Category

Change Default Storage Engine in MySQL

Jan
30

I like my default engine to be InnoDB because it’s fully transactional and supports foreign key references. However, the default engine in MySQL is MyISAM.

There are several ways to change the default storage engine:

  1. Add default-storage-engine = innodb to your /etc/mysql/my.cnf under mysqld server section
  2. The default storage engine can be specified at server startup with the –default-storage-engine option.
  3. For a running server, an administrator who has the SUPER privilege can change the default storage engine globally for all clients by setting the global storage_engine system variable:
    SET GLOBAL storage_engine = innodb;

    Setting the storage engine this way affects any client that connects after the statement executes. Clients that are connected at the time of statement execution are unaffected.

  4. Any client can change its own default storage engine by issuing either of these statements:
    SET SESSION storage_engine = innodb;
    SET storage_engine = innodb;
    

If you change your default storage engine using Method 1, you can optimize the performance by adding few more instructions, as explained in this Stack Overflow post.

I use Method 1, and I added 3 lines to my /etc/mysql/my.cnf:

Under [mysqld] :

default-character-set = utf8
default-storageengine = innodb

… then I also added this line in InnoDB section:

innodb_buffer_pool_size = 512M

Removing Your Site from Search Engine Crawler

Jan
30

Don’t want search engine like Google to include your site in the search results?

Create a file called “robots.txt” on your root HTML directory, the path where your main site’s URL belongs: http://www.yoursite.com/

This is normally located in www directory or public_html.

In this file, add these lines:

User-agent: *
Disallow: /

“Disallow” property indicates the path that you don’t want to be crawled/searched by search engines, including its child URL. In the example above, your site will be completely removed from search engine results as the main URL is disallowed.

If you want to exclude only certain child URLs, you can do write something like this:

User-agent: *
Disallow: /about
Disallow: /secret

Useful Web Dev Articles This Week

Dec
1

Top 20+ MySQL Best Practices

9 Most Common IE Bugs and How to Fix Them

Zen Coding: A Speedy Way To Write HTML/CSS Code