20 May

Cannot connect to MySQL server on ‘localhost': Cacti Error

I was installing and setting up Cacti recently and faced following error:

“FATAL: Cannot connect to MySQL server on ‘localhost’.”

This post includes debugging steps and solution for the issue.

Along with the Cacti’s web-interface, the poller.php was generating the same error as follows:

root@ubuntu:/var/www/cacti# php /var/www/cacti/poller.php
FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'

Read More

28 Apr

How-to extract from mysqldump | mysql-dump-splitter recipes

The latest mysqldumpsplitter (v 5.0) is out. I’d like to make it easier for everyone to get started with it.  So in this post you’ll get a quick & handy command-line “recipe” for extracting table, database  or more from mysqldump.

The Mysqldumpsplitter can extract database, table, all databases, all tables or tables matching on regular expression. It can also extract multiple tables from one database or describe the contents from a mysqldump.

The tool can extract a MySQL database from a compressed or uncompressed mysqldump. It by default produces the compressed output of sqls in default out directory but you can specify target directory or uncompressed output as well.

Check out more  on recipe commands to use the mysqldumpsplitter.

Continue Reading…

23 Mar

MySQL:The user specified as a definer does not exist (error 1449)-Solutions

The self-explanatory error that led this post is:
MySQL error 1449: The user specified as a definer does not exist.
I wrote about DEFINER & INVOKER SQL SECURITY in MySQL long back in early 2012 which covers the explanation of how they work WRT stored routines in MySQL!

Here I’ll try to extend it little more with examples for the error and provide 3 solutions.
Continue Reading…

10 Mar

10 useful shell script code snippets | Linux

This post is collection of 10 useful unix / linux shell script code snippets I’ve often used.

Following these code snippet you will be able to answer following questions:
1. How to calculate script run-time in shell.
2. How to parse parameters / arguments to shell script.
3. How to safely change a directory in shell script.
4. How to check if a command was successful in shell script.
5. How to add timestamps in script log output.
6. How to check if a process is running.
7. How to colour your script output.
8. How to read variables from config file.
9. How to loop over files in a folder.
10. How to perform actions based on variable value using SWITCH…CASE

Let’s begin.
Continue Reading…

23 Feb

Restore / Recover dropped MySQL database from binary logs

In this post I will share a recovery scenario of a MySQL database restore from the binary logs.

Recently someone accidentally dropped an important MySQL database and the backup was not present!

As we know the the binary log contains DMLs to table data and that’s where our hope lies. Luckily the binary log retention period (expire_logs_days) was set to 30 days and the CREATE DATABASE was still present in the binary logs.

Thus this restore of the dropped MySQL database can be done from extracting respective DMLs point-in-time. Here we will play the binary logs against a temporary MySQL instance and extract the required database.

Let’s begin the recovery of database.
Continue Reading…

-- Kedar Vaijanapurkar --