Skip to main content

Posts

Mysql Script to install and run mysql instance on linux box

Here is the shell script that will install mysql version 5.5 on a new instance. sh -xv /root/clean_install.sh The mysql data directory (/data/mysql/jun19) should be changed in 2 places. #!/bin/sh ## disable selinux /usr/sbin/setenforce 0 ## shut-down mysql if already running mysqladmin shutdown # remove old data directory rm -rf /var/lib/mysql/ rm -rf /root/download ## create required directories # datadir mkdir -p /data/mysql/jun19 # pid directory mkdir -p /var/run/mysql # default socket directory mkdir -p /var/lib/mysql # download directory mkdir /root/download cd /root/download wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-client-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-devel-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.20/MySQL-server-5.5.20-1.linux2.6.x86_64.rpm wget http://files.directadmin.com/services/all/mysq...

MySQL Multi-Master Replication Manager

MMM  ( M ulti- M aster Replication  M anager for  MySQL ) is a set of flexible scripts to perform monitoring/failover and management of  MySQL  master-master replication configurations (with only one node writable at any time). The toolset also has the ability to read balance standard master/slave configurations with any number of slaves, so you can use it to move virtual IP addresses around a group of servers depending on whether they are behind  in  replication. The current version of this software is stable, but the authors would appreciate any comments, suggestions, bug reports about this version to make it even better. Current version 2.0 development is led by Pascal Hofmann. If you require support, advice or assistance with deployment, please contact  Percona  or  Open Query . Latest bugs (2.x) [911277] Monitor sets ip first after changing state from ADMIN_OFFLINE to ONLINE [897099] the value of auto_set_online is ...

MySQL Commands to real time monitoring and usage

$ mysqldump db_name my_table $ mysqldump db_name my_table > output.sql $ mysqldump --no-data db_name my_table > dump_table_name.sql $ mysqldump --add-drop-table db_name my_table > dump_table_name.sql $ mysqladmin create db_name $ mysqladmin drop db_name $ mysqladmin flush-privileges $ mysqladmin ping $ mysqladmin reload $ mysqladmin kill ps_id,ps_id... $ mysqladmin --user=root shutdown $ mysqladmin variables $ mysqlimport db_name file_name ... $ safe_mysqld $ myisamchk table_name.MYI mysql> GRANT ALL ON db_name TO user_name@localhost IDENTIFIED BY 'password' mysql> GRANT ALL ON db_name TO user_name@'%' IDENTIFIED BY 'password' $ mysql --help | less $ mysqld --help $ mysqlshow --help | less $ mysqldump --help | less $ mysqlshow      - show all databases. $ mysqlshow db_name - all tables in particular database. $ mysqlshow db_name BA* - all tables which start from BA letters. mysql> \? m...

MySQL load table data using dot SQL file on command line

$ vi create_table.sql ( open new file ) --------------------- drop table if exists my_table; create table my_table (ID int not null primary key, l_name         varchar(20) not null, f_name varchar(20)); insert into my_table values (1,"Frost",'Robert'); insert into my_table (ID,l_name) values (2,'Smith'); select * from my_table; :wq ( save file ) ----------------- $ mysql db_name < create_table.sql $ mysql db_name -t < create_table.sql > output.sql mysql> \. create_table.sql

MySQL CRUD Operations Creating Table Read Update and Drop

mysql> drop table if exists my_table; mysql> create table my_table (ID int not null primary key, l_name     -> varchar(20) not null, f_name varchar(20)); Query OK, 0 rows affected (0.08 sec) mysql> describe my_table; +--------+-------------+------+-----+---------+-------+ | Field   | Type         | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | ID      | int(11)      |       | PRI | 0        |        | | l_name | varchar(20) |       |      |          |        | | f_name | varchar(20) | YES   |      | NULL     |        | +--------+-------------+----...