This blog basically deals with the how to troubleshoot the problems related to the mysql.
Thursday, 1 December 2011
Step by step process for how to set the mk-heartbeat monitoring
Monday, 17 October 2011
MySQL replication set up
Wednesday, 12 October 2011
MySQL startup issue
If you are facing problem in starting the mysql server try to start mysqld with the option –verbose it will tell what is the problem or you can also check the problem by your error log file.
Take a case here
abdul@system:~$ mysqld --verbose --user=mysql –datadir=/var/lib/mysql/ &
[1] 2975
abdul@system:~$ 111013 10:42:35 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
111013 10:42:35 [Warning] Can't create test file /var/lib/mysql/OSS-240.lower-test
111013 10:42:35 [Warning] Can't create test file /var/lib/mysql/OSS-240.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
111013 10:42:35 [ERROR] Aborting
111013 10:42:35 [Note] mysqld: Shutdown complete
Above wee see that we are getting error code 13.means its permission issue login as root and now try.
root@system:~$mysqld --verbose --user=mysql --datadir=/var/lib/mysql/ &
now mysql is running & working properly.
But one point you should consider in mind is that we have written –user=mysql.
Always try to start your mysql server as mysql user if you start it as root its not a good practice.
Tuesday, 11 October 2011
Restore your data using mysqlbinlogs
Its a simple article on How you can restore your data using mysql binary logs.
mysql binary logs contain a record of each SQL query executed against the database that changes data since the logs where last flushed (new log file started).MySQL Binary Logs must be enabled by passing the –log-bin option to mysqld.
The log contains queries like UPDATE and DELETE. The log does not record SELECT or SHOW queries for example because they do not change the database.
MySQL Binary Logs are some times confused with the InnoDB binary transaction log. InnoDB uses a binary log to journal changes to the InnoDB table space file(s) as a protection from crashes to protect table space data integrity.
When --log-bin is enabled even InnoDB transactions are written to the binary transaction log used for replication or restores.
At this time take a scenario you has binary logs as follows:
see the location where binary logs are stored.
localhost-bin.000001
localhost-bin.000002
localhost-bin.000003
localhost-bin.index
firstly lock the tables as
LOCK TABLES
then flush the logs as
FLUSH LOGS
At this time take a scenario you has binary logs as follows:
see the location where binary logs are stored.
localhost-bin.000001
localhost-bin.000002
localhost-bin.000003
localhost-bin.000004
localhost-bin.index
after flushing the logs a new bianry log generated as localhost-bin.000004.
Now upto binary log localhost-bin.000003 you can take the complete backup.
take the backup using any method that you want.
This is you complete backup upto the log localhost-bin.000003
Then unlock the tables as
UNLOCK TABLES
Restoring with Binary Logs
To restore from a point in time using binary logs you would:
Restore the database from the last SQL Dump completed before the desired recovery point.
Use mysqlbinlog to restore to the desired point in timewhere N is the log entry number you want to restore up to.
mysqlbinlog –start-position=N localhost-bin.000004 | mysql N is the position of binary log.
Monday, 10 October 2011
How to reduce the ibdata space in Mysql
Dump the Whole Database
This is the easiest method How to reclaim the ibdata space
In fact, this is the method I used to solve the problem. It requires much more space and time but it’s maybe the easiest one. So here it is:
Dump all databases by using:
mysqldump -uroot -proot --extended-insert --all-databases --add-drop-database --disable-keys --flush-privileges --quick --routines --triggers > all-databases.sql
Stop the MySQL server;
/etc/init.d/mysql stop
Rename or remove the MySQL data directory and create an empty one with the same name and permissions;
i.e In case the datadir is /var/lib/mysql then remove the all content of that.
else remove /var/lib/mysql and create other one with the same permission and same name.
Make the appropriate changes in my.cnf.
Re-initialize the database with the following command.
sudo -u root mysql_install_db
Start the MySQL server;
/etc/init.d/mysql start
Get into the ‘mysql‘ console and type:
SET FOREIGN_KEY_CHECKS=0;
SOURCE all-databases.sql;
SET FOREIGN_KEY_CHECKS=1;Restart the MySQL server.
At this point of time everything should be running fine.
Wednesday, 10 August 2011
Running Multiple Mysql server
Just what we have to do is the start the server (mysqld_safe) with different option's and also this applies for the client(mysql). I have installed the two MySql servers Now i want them to be started with different basedir,datadir,socket etc..
1. I have Installed the One Mysql Server with the apt-get and other as binary.
2. Install the first one Simply as apt-get install mysql-server.
3. The binary Installation is as from
/usr/local/mysql/support-
Now start the server as running below with options.( mysqld_safe with the various options)
root 6910 6887 0 15:14 pts/5 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/mysql/my.
mysql 7005 6910 0 15:14 pts/5 00:00:00 /usr/sbin/mysqld --defaults-file=/etc/mysql/my.
root 7020 6887 0 15:16 pts/5 00:00:00 mysql -p
root 7046 6356 0 15:19 ? 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/etc/mysql/my-
mysql 7150 7046 0 15:19 ? 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/mysql/my-
root 7220 7193 0 15:20 pts/4 00:00:00 grep mysql
We also need to edit our my.cnf file for the as we have to start the server with the options of --defaults-file as it include the socket and port.
The socket and port for both the cnf file should different and also all other datadir, basedir .......
Now run your mysql client with --port and --socket option.