November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Mysql Master-Slave Replication after slave fails

1. From slave if we run mysql> mysql slave status; it will show last bin file slave reads from master and all,so start from that bin file to sink with master to slave.

2. Set Master configuration on the Slave. Execute the following command on a MySQL prompt to sink slave with master:

mysql > […]

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 […]

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 […]

Resetting MySQL Root Password: Red Hat and CentOS

If you’ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Red Hat (RHEL) system or a CentOS system:

Stop MySQL:

root# service mysqld stop

Start MySQL in safe mode:

root# mysqld_safe –skip-grant-tables &

Log into MySQL as root:

[…]

MySQL Commands for reference

The following MySQL Commands were originally split into several smaller blog posts that I had built up over the years, I have now consolidated the articles into a single post (feel free to link to this resource from your site).

Please note this article contains commands & examples for the mysql command line client, it […]

MySQL ERROR 1045 Access denied for ‘user’@’localhost’

The Problem

The logfile of mysqld, /var/log/upstart/mysql.log, reported yet another error:

?120618 14:07:31 [Note] /usr/sbin/mysqld: ready for connections.

Version: ‘5.5.24-0ubuntu0.12.04.1’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 (Ubuntu)

mysqld is alive

Checking for tables which need an upgrade, are corrupt or were

not closed cleanly.

120618 14:07:36 [ERROR] Cannot find or open table nova/projects from

the internal […]

Optimizing my.cnf file for MySQL

[mysqld] socket=/path/to/mysql.sock datadir=/var/lib/mysql skip-locking skip-innodb # MySQL 4.x has query caching available. # Enable it for vast improvement and it may be all you need to tweak. query_cache_type=1 query_cache_limit=1M query_cache_size=32M # max_connections=500 # Reduced to 200 as memory will not be enough for 500 connections. # memory=key_buffer+(sort_buffer_size+read_buffer_size)*max_connections # which is now: 64 + (1 + […]