Skip to content

Instantly share code, notes, and snippets.

root@hudexchange-web:/var/www/vmhost/apps/hudexchange/scraps/mariadb_docker/replication/bergerx# dockerComposeVersion=1.13.0
root@hudexchange-web:/var/www/vmhost/apps/hudexchange/scraps/mariadb_docker/replication/bergerx# curl -L https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-`uname -s`- `uname -m` > /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 3554 0 --:--:-- --:--:-- --:--:-- 3566
100 8079k 100 8079k 0 0 367k 0 0:00:21 0:00:21 --:--:-- 417k
root@hudexchange-web:/var/www/vmhost/apps/hudexchange/scraps/mariadb_docker/replication/bergerx# chmod +x /usr/local/bin/docker-compose
root@hudexchange-web:/var/www/vmhost/apps/hudexchange/scraps/mariadb_docker/replication/bergerx# ./start.sh
+ export MYSQL_ROOT_PASSWORD=Oakton153
+ MYSQL_ROOT_PASSWORD=Oakton153
@olublessed
olublessed / clean.sh
Created July 21, 2017 21:07 — forked from codersofthedark/clean.sh
MySQL Replication: 'Duplicate entry for PRIMARY key'
while [ 1 ]; do if ['mysql -uroot -ppassword -e"show slave status \G;" | grep "Duplicate entry" | wc -l' -eq 2 ] ; then mysql -uroot -ppassword -e"stop slave; set global sql_slave_skip_counter=1; start slave;"; fi; sleep 1; mysql -uroot -ppassword -e"show slave status\G"; done
@olublessed
olublessed / mysql_secure.sh
Created July 25, 2017 14:23 — forked from Mins/mysql_secure.sh
Automating mysql_secure_installation
#!/bin/bash
aptitude -y install expect
// Not required in actual script
MYSQL_ROOT_PASSWORD=abcd1234
SECURE_MYSQL=$(expect -c "
set timeout 10
@olublessed
olublessed / Bash MySQL backupo script
Created July 27, 2017 21:21 — forked from walterheck/Bash MySQL backupo script
Backup script for MySQL backups locally, both mysqldumps and binary backupos using percona's xtrabackup
#!/bin/bash
# Configuration
. /etc/mysql/mysql_backup.conf
# Dump the mysql databases to a daily dump file.
function log()
{
logger -i -p daemon.info -t mysqldump "$1"
echo $1 >> $LOGFILE
# # MySQL Galera Cluster 5.5.34-25.9/Galera 2.8/Ubuntu 12.04 64bit
FROM ubuntu:12.04
MAINTAINER Severalnines AB <[email protected]>
RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
RUN sed -i '/repo.percona.com/d' /etc/apt/sources.list
RUN sh -c 'echo "deb http://repo.percona.com/apt precise main" >> /etc/apt/sources.list'
RUN sh -c 'echo "deb-src http://repo.percona.com/apt precise main" >> /etc/apt/sources.list'
RUN apt-get -q -y update
RUN LC_ALL=en_US.utf8 DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::='--force-confnew' -qqy install nano wget psmisc libdbi-perl libdbd-mysql-perl libwrap0 perl libaio1 mysql-client percona-xtrabackup libssl0.9.8 libssl1.0.0 rsync netcat
RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && sed -i '/repo.percona.com/d' /etc/apt/sources.list && sh -c 'echo "deb http://repo.percona.com/apt precise main" >> /etc/apt/sources.list' && sh -c 'echo "deb-src http://repo.percona.com/apt precise main" >> /etc/apt/sources.list' apt-get -q -y update && apt-get -o Dpkg::Options::='--force-confnew' -qqy install nano wget psmisc libdbi-perl libdbd-mysql-perl libwrap0 perl libaio1 mysql-client percona-xtrabackup libssl0.9.8 libssl1.0.0 rsync netcat && wget --no-check-certificate https://launchpad.net/codership-mysql/5.5/5.5.34-25.9/+download/mysql-server-wsrep-5.5.34-25.9-amd64.deb && wget --no-check-certificate https://launchpad.net/galera/2.x/25.2.8/+download/galera-25.2.8-amd64.deb && dpkg -i galera-25.2.8-amd64.deb && dpkg -i mysql-server-wsrep-5.5.34-25.9-amd64.deb
Get:38 http://archive.ubuntu.com precise-security/universe i386 Packages [197 kB]
Fetched 28.5 MB in 42s (666 kB/s)
Reading package lists...
W: GPG error: http://repo.percona.com precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9334A25F8507EFA5
WARNING: The following packages cannot be authenticated!
libmysqlclient18 percona-xtrabackup
E: There are problems and -y was used without --force-yes
The command '/bin/sh -c apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && sed -i '/repo.percona.com/d' /etc/apt/sources.list && sh -c 'echo "deb http://repo.percona.com/apt precise main" >> /etc/apt/sources.list' && sh -c 'echo "deb-src http://repo.percona.com/apt precise main" >> /etc/apt/sources.list' && apt-get -q -y update && apt-get -o Dpkg::Options::='--force-confnew' -qqy install nano wget psmisc libdbi-perl libdbd-mysql-perl libwrap0 perl libaio1 mysql-client percona-xtrabackup libssl0.9.8 libssl1.0.0 rsync netcat && wget --n
@olublessed
olublessed / sql_backup.sh
Created August 23, 2017 19:33 — forked from niraj-shah/sql_backup.sh
Amazon S3 Backup Script for MySQL Databases
#!/bin/bash
# Shell script to backup MySql database
# CONFIG - Only edit the below lines to setup the script
# ===============================
MyUSER="root" # USERNAME
MyPASS="password" # PASSWORD
MyHOST="localhost" # Hostname
ERROR 1146 (42S02) at line 31 in file: './views/p_s/ps_check_lost_instrumentation_57.sql': Table 'performance_schema.global_status' doesn't exist
ERROR 1146 (42S02) at line 32 in file: './views/p_s/memory_by_user_by_current_bytes.sql': Table 'performance_schema.memory_summary_by_user_by_event_name' doesn't exist
ERROR 1146 (42S02) at line 32 in file: './views/p_s/x_memory_by_user_by_current_bytes.sql': Table 'performance_schema.memory_summary_by_user_by_event_name' doesn't exist
ERROR 1146 (42S02) at line 32 in file: './views/p_s/memory_by_host_by_current_bytes.sql': Table 'performance_schema.memory_summary_by_host_by_event_name' doesn't exist
ERROR 1146 (42S02) at line 32 in file: './views/p_s/x_memory_by_host_by_current_bytes.sql': Table 'performance_schema.memory_summary_by_host_by_event_name' doesn't exist
ERROR 1146 (42S02) at line 35 in file: './views/p_s/memory_by_thread_by_current_bytes.sql': Table 'performance_schema.memory_summary_by_thread_by_event_name' doesn't exist
ERROR 1146 (42S02) at line 35
@olublessed
olublessed / mysql-docker.sh
Created July 10, 2018 13:39 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE