July 2013
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  

Categories

July 2013
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  

MySQL Backup

#! /bin/bash

 

# your MySQL server’s name SERVER=test.net

# directory to backup to BACKDIR=~/backups

# date format that is appended to filename DATE=`date +’%m-%d-%Y’`

#———————-MySQL Settings——————–#

# your MySQL server’s location (IP address is best) HOST=localhost

# MySQL username USER=username

# MySQL password PASS=password

# List all of the MySQL databases that you want […]

How to Grant Privileges to Users in MySQL

How to Grant Privileges to Users in MySQL

 

MySQL stores all its username and password data in a special database named mysql. You can add users to this database and specify the databases to which they will have access with the grant command, which has the syntax.

sql> grant all privileges on database.* to […]

ALTER TABLE syntax – MySQL

ALTER TABLE syntax – MySQL

 

You can then import it into a MySQL table by running:

 

#load data local infile ‘file.csv’ into table tablename

fields terminated by ‘,’

enclosed by ‘”‘

lines terminated by ‘\n’

(field1, field2, field3)

Basic MySQL Commands

Basic MySQL Commands

 

To login (from unix shell) use -h only if needed.

#mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in […]

Setup Mysql Replication Between Linux(master) & Windows XP(Slave)

Step 1 – Configure the Master Server

First we have to edit /etc/mysql/my.cnf. We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):

#skip-networking

#bind-address = 127.0.0.1

Furthermore we have to tell MySQL for which database it should write logs (these logs […]

Assign Virtual IPs to your NIC

Edit file /etc/sysconfig/network-scripts/ifcfg-eth0.

DEVICE=eth0

BOOTPROTO=static

BROADCAST=192.168.0.255

HWADDR=00:00:00:00:00:00

IPADDR=192.168.10.2

NETMASK=255.255.255.0

NETWORK=192.168.10.0

ONBOOT=yes

TYPE=Ethernet

GATEWAY=192.168.10.1

 

Make a copy of this in the same directory naming the new file ifcfg-eth0:1

# cp ifcfg-eth0 ifcfg-eth0\:1

 

Modify /etc/sysconfig/network-scripts/ifcfg-eth0:1 file. Modification are in bold

DEVICE=eth0:1

BOOTPROTO=static

BROADCAST=192.168.0.255

HWADDR=00:00:00:00:00:00

IPADDR=192.168.10.101

NETMASK=255.255.255.0

NETWORK=192.168.10.0

ONBOOT=yes

TYPE=Ethernet

GATEWAY=192.168.10.1

# cp ifcfg-eth0\:1 /etc/sysconfig/networking/devices/

[…]

How to take Linux backups powered by Rsync

RSync backups data and does it very clean and well. Rsync only transfers those data that have been modified and changed so that the destination host has an exact replica from the source host. Rysnc is a command line backup tool that handles data transfers in an effective and secure manner like any other known […]

How to Prevent the reuse of old passwords

For RHEL/Fedora distribution

To remember the last 5 passwords, add the line below to the file /etc/pam.d/system-auth file:

password sufficient /lib/security/pam_unix.so use_authtok md5 shadow remember=5

For Debian/ubuntu distribution

To remember the last 5 passwords, add the line below to the file /etc/pam.d/common-password file:

password sufficient /lib/security/pam_unix.so use_authtok md5 shadow remember=5

Mysql Replication status notification

Using the script you can get the alert message from the replication server if replication is down or not working.

——————————————————————————————–

#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

#script checking the replication is running or not.

#If replication is down then sent the alert mail.

slave_server_hostname=192.168.10.1

###check if already notified###

cd /root

if [ -f slave_problem.txt ]; then

rm -rf […]

Database Replication In MySQL

Database Replication In MySQL

 

Configure the MySQL Master Server

Step 1 : edit /etc/mysql/my.cnf file.

#skip-networking

#bind-address = 127.0.0.1

(add below line in /etc/mysql/my.cnf file)

server-id = 1

log_bin = /var/log/mysql/mysql-bin.log

binlog_do_db = replicationdb

step 2 : Restart Mysql server

#/etc/init.d/mysql restart

Step 3 : create a user with replication privileges:

#mysql -u […]