Saturday 21 July 2012

How to run multiple MySQL instances on Unix

There are a few ways to run multiple MySQL instances on the same Unix machine.

1. compile a MySQL server with a different TCP/IP port and socket file


 I don't really like it because it doesn't need to be that complicated. I'd like to have more control on the application level.

 2. use the same MySQL server and specify different TCP/IP port and socket file using command line option


For eaxmple: mysqld_safe --socket=file_name --port=port_number --datadir=new_path

I don't like it either because too many options in command line is not good for management.

3.  use mysqld_multi to manage multiple MySQL servers


This is my favour. You can use one my.cnf to specify different options of your MySQL instance and use command mysqld_multi to start/stop a single instance. It is much easier for you to manage your multiple servers.

Edit your cnf file as follows

[mysqld_multi]
mysqld = /usr/local/bin/mysqld_safe
mysqladmin = /usr/local/bin/mysqladmin

[mysqld1]
.
.
port=3306
datadir=/home/mysql-data-1
.
.

[mysqld2]
.
.
port=3307
datadir=/home/mysql-data-2
.
.

Now you are ready to start your multiple MySQL database servers

mysqld_multi start 1
mysqld_multi start 2


To log into your MySQL database server

mysql -uusername -p -h127.0.0.1 -P3306
mysql -uusername -p -h127.0.0.1 -P3307


To shutdown a MySQL database server

mysqladmin -uusername -p -h127.0.0.1 -P3306
mysqladmin -uusername -p -h127.0.0.1 -P3307


If you are having problems starting your new MySQL database server, carefully analyse your mysqld log files. If you see errors like "mysql.host does not exist", you may need to initialize the database in the new server and it should be good to go

mysql_install_db --user=mysql --datadir=new_db_directory
chown -R mysql:mysql new_db_directory

Friday 20 July 2012

Re: 1997 camry

I have been spammed many times with the same inquires on gumtree. I'm curious that the pattern is always the same. It only happens when you are selling a car. Probably that is the most valuable stuff you can find in gumtree and it is worth a treat?

Anyway, the story always begins with me posting an ad on gumtree, selling my car. Some one, there is always some one who immediately replies you expressing their interests. They will have many excuses for not being able to meet you personally. Either they are busy with work, or they are not in the same area, or even they are not in Australia but are willing to ship your car their country (so far most ridiculous one). They are willing to send you money via PayPal and will ask for your PayPal email address.

I'm not sure what they can do with your PayPal email address. I guess they will try to request money from you. If you are not familiar with PayPal and anyhow click on approve, your money will be gone. Apart from this, I have no idea what they can do.

I was bored last night and was teasing with this person. Have fun



On 07/19/2012 11:58 PM, Lori Parker wrote:
Okay I will be of any help..just send me an email and I will respond.

Thanks

On Thu, Jul 19, 2012 at 11:56 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

I'm sorry, it is too late for me now. I'll come back to this tomorrow. Once I set up paypal, I'll let you know my paypal email address ID. I may have additional questions during the sign up and may need your help.

Thank you for your help and you have a good night.

Cheers
NingNing



On 07/19/2012 11:51 PM, Lori Parker wrote:
choose personal

On Thu, Jul 19, 2012 at 11:51 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

What is the difference between personal, premier, and business? Can I choose premier?

Cheers
NingNing



On 07/19/2012 11:48 PM, Lori Parker wrote:
choose personal

On Thu, Jul 19, 2012 at 11:42 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

I'm new to paypal, so I clicked on sign up. What is personal, premier, and business? Which one do I choose?

Cheers
NingNing



On 07/19/2012 11:36 PM, Lori Parker wrote:
What you need to send to me is your PayPal email....for example my PayPal is the same with my email.

On Thu, Jul 19, 2012 at 11:33 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

I went to paypal.com.au, clicked on log in, entered my email address, what is my paypal password?

Cheers
NingNing



On 07/19/2012 11:28 PM, Lori Parker wrote:
PayPal is very east to set up..just log on to www,paypal,com.au and register when you are done send me the email you used for registration so i can pay in and as soon as the funds is paid you will receive a confirmation email from PayPal notifying you about the funds.

On Thu, Jul 19, 2012 at 11:23 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

Thank you for your quick reply.

I'm sorry I don't know how to set up paypal. It is too complicated to me. Could you give cash instead?

Cheers
NingNing



On 07/19/2012 11:19 PM, Lori Parker wrote:
Hi mate,thanks for the reply.I have read the ad and it's okay by me.My work does not permit me to come for the inspection (very busy and currently out of town). Would have loved to call but our base right now is bad so we can get along via e-mail. I will be paying you through PayPal,please get back to me with your PayPal email ID so i can proceed with the payment immediately and if you don't have one it's very easy to set up visit (www.paypal.com.au).Please ignore further enquiries from other buyers,you don't have to surf around looking for buyers as you have just found one.

Note:Please provide your address in your reply so that my shipping agent can locate you when coming for the pick up.

Thanks

On Thu, Jul 19, 2012 at 11:14 PM, NingNing Wang <xxx@xxx> wrote:
Hi Lori:

I'm replying your message regarding the 1997 Camry for sale at $2990.

I'm happy with your offer of an extra $200 for quick sale.

What time would you like to come pick up the car?

Cheers
NingNing






Wednesday 18 July 2012

How to redirect to mobile site using htaccess

Do not redirect to your mobile site using javascript or PHP script. It wastes resources to execute the script. The right place to redirect to your mobile site is in .htaccess file. If you have proper redirect rules set up in the .htaccess file, the web server will forward the visitor to your mobile website before it executes the script.

The following set of rewrite rules will redirect all smart phone devices to a specific mobile website.

Simple Version of Rewrite Rules


# turn on rewrite engine
RewriteEngine on

# only detect smart phone devices if we are not on mobile site
# to prevent redirect looping
RewriteCond %{HTTP_HOST} !^m.mysite.com$

# a bunch of smart phone devices
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "iemobile|opera mobile|palmos|webos"[NC,OR]

# redirect google mobile bot
RewriteCond %{HTTP_USER_AGENT} "googlebot-mobile"[NC]

# if the request is from any one of the above devices
# redirect to mobile site
RewriteRule .? http://m.mysite.com%{REQUEST_URI}  [L,R=302]

Complete Version of Rewrite Rules


# turn on rewrite engine
RewriteEngine on

# only detect smart phone devices if we are not on mobile site
# to prevent redirect looping
RewriteCond %{HTTP_HOST} !^m.mysite.com$

# a bunch of smart phone devices
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "windows ce|epoc|opera|mini|nitro" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "j2me|midp-|cldc-|netfront|mot" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up\.browser|up\.link|audiovox" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "netfront|mot|up\.browser|up\.link"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "audiovox|blackberry|ericsson,"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|dange"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "alcatel|ericy|vodafone\/|wap1\."[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wap2\.|iPhone|android"[NC,OR]

# redirect google mobile bot
RewriteCond %{HTTP_USER_AGENT} "googlebot-mobile"[NC]

# if the request is from any one of the above devices
# redirect to mobile site
RewriteRule .? http://m.mysite.com%{REQUEST_URI}  [L,R=302]

Search Engine Optimization (SEO)

SEO is not hard to learn. You will find tons of SEO guides or tips over the Internet + the official starter guide from Google. As long as you understand how search engine works, you will know how to design your web page and how to write your content efficiently - efficiently to be more explosive to all search engines.

Below are the tips to help you start with search engine optimization. Please keep it in mind that SEO is a on-going task. You should keep analysing the performance of your website and update your contents accordingly. Fresh content is always the favour of search engine.

1. keywords
  • meta tag "keywords" is not important to google search engine any more
  • however, it is still ranked as #1how search engine measures your page
  • carefully choose your keywords based on the content of your page
  • monitor the keywords performance of your site in google analytics closely and focus on search phases
2. back links
  • build quality links using your keywords
  • build links to your site and within your site using your keywords
3. meta tag - title
  • should be placed within <head> tag
  • will usually appear in the first line of the results
  • create unique title tag for each page
4. meta tag - description
  • should be placed within <head> tag
  • create unique description tag for each page
5. url structure
  • try to use relevant words in the url. Example: seo.html is better than page1.html
  • use simple directory structure. Example: ../doc/seo.pdf is better than ../doc/google/au/en/seo/2012/07/18/v1/seo.pdf
  • specify your canonical
6. sitemap
  • prepare one sitemap for users
  • prepare one XML sitemap for search engines. If you are not sure how, use some online sitemap generator tools.
7. 404 page
  • allow visitors to navigate to home page or other pages on a 404 page
  • provide customer support information on a 404 page
8. quality content
  • write easy-to-read text
  • write unique content
  • use paragraphs, heading properly
9. image
  • always specify a descriptive text of "alt" attribute
10. social marketing
  • broadcast your sites on social media sites such as Facebook, Twitter, etc