Restore MySQL database from binary log

MySQL Cluster

To learn more about what is binary log and how to setup Click here MySQL binary log : mysqlbinlog utility mysqldump – MySQL Database Backup and restore program Purge Binary log MySQL Master-Master-Slave-Slave Replication Database Recover from MySQL binary log: Binary logs store all the queries (in STATEMENT format) or row changes (in ROW format) … Read more

MySQL binary log : mysqlbinlog utility

MySQL Cluster

Mysql binary log is a special kind of logging facility provided by MySql by which we can record the log of the database changes statement along with the moment when statement get executed. We can log all insert, update and delete statement of the database in the mysql binary log. What is MySQL binary log? … Read more

Kill slow mysql queries

MySQL Cluster

A Shell script for killing slow MySQL queries: #!/bin/sh # Credentials for a MySQL user with PROCESS, SUPER permissions USERNAME= PASSWORD= # MySQL Server location HOST= PORT=3306 TIMEOUT=60 # 1 minute TARGET_USER= # MySQL user to monitor MYSQL=”mysql -u $USERNAME –password=$PASSWORD -h $HOST -P $PORT -B” $MYSQL -N -e ‘SHOW FULL PROCESSLIST’ | cut -f … Read more

Purge Binary log

MySQL Cluster

If you have enabled binary logging for the point-in-time recovery (or using replication in your environment) option and forgot to purge it then it may eat up memory in no time, so to “purge” binary logs from production server follow the steps(depending upon your environment) List the current binary logs List the current binary logs … Read more

Python Function

python tutorial

What are functions? Functions are a convenient way to divide your code into useful blocks, allowing us to order our code, make it more readable, reuse it and save some time. Functions are a key way to define interfaces so programmers can share their code. Function is a block of organized, reusable code that is … Read more

ntp – installation and configuration

ntp server

You need to install the following packages: ntp : ntpd server which continuously adjusts system time and utilities used to query and configure the ntpd daemon. ntpdate : Utility to set the date and time via NTP. ntp-doc : NTP documentation Open the terminal or login over the ssh session. You must login as as … Read more

MySQL trim function

MySQL Cluster

MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string. Syntax TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str) Arguments Name Description BOTH Indicates that prefixes from both left and right are to be removed. LEADING Indicates that only leading prefixes are to be removed. TRAILING Indicates that … Read more

PHP – MySQL : Create Database

php-mysql

  [root@mysqlDB]# mysqladmin -u root -p create eduguru Enter password:****** This will create a MySQL database eduguru. This is a simple example to create database called eduguru. Example: <?php $dbhost = ‘localhost:3036’; //If mysql server is on same server $dbuser = ‘root’; //mysql user who has the permission to create database $dbpass = ‘rootpassword’; //mysql user’s password … Read more

MySQL RAND Function

MySQL Cluster

MySQL has a RAND function that can be invoked to produce random numbers between 0 and 1: mysql> SELECT RAND( ), RAND( ), RAND( ); +——————+—————–+——————+ | 0.45464584925645 | 0.1824410643265 | 0.54826780459682 | +——————+—————–+——————+ 1 row in set (0.00 sec) When invoked with an integer argument, RAND( ) uses that value to seed the random … Read more

mysql locate function

MySQL Cluster

MySQL LOCATE() returns the position of the first occurrence of a string within a string. Both of these strings are passed as arguments. An optional argument may be used to specify from which position of the string (i.e. string to be searched) searching will start. If this position is not mentioned, searching starts from the … Read more