SQLBackupAndFTP - Database Backup Tool Free Version
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
October 30, 2020
September 16, 2016
Upgrading MySQL 5.3 to 5.6 MySQL Daemon failed to start (CentOS 6)
Operating System: CentOS 6.8
Arch : x86_64
Arch : x86_64
Symptom MySQL service failed to start after upgrading from MySQL 5.3.3 to 5.6 version.
Given below is the error found after upgrading to MySQL server version 5.6 from 5.3. You can get the below error in MySQL error log file.
2014-11-29 02:22:56 2175 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2014-11-29 02:22:56 2175 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2014-11-29 02:22:56 2175 [ERROR] Plugin ‘InnoDB’ init function returned error.
2014-11-29 02:22:56 2175 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
2014-11-29 02:22:56 2175 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-11-29 02:22:56 2175 [ERROR] Aborting
2014-11-29 02:22:56 2175 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2014-11-29 02:22:56 2175 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2014-11-29 02:22:56 2175 [ERROR] Plugin ‘InnoDB’ init function returned error.
2014-11-29 02:22:56 2175 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
2014-11-29 02:22:56 2175 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-11-29 02:22:56 2175 [ERROR] Aborting
Solution :
To solve this problem add the below given line in /etc/my.cnf file inside
[mysqld]
block.innodb_data_file_path = ibdata1:10M:autoextend
Now restart the mysql service.
service mysqld restart
I hope the issue is resolved for you also.
August 25, 2016
MYSQL BAKUP USING SHELLS SCRIPTS
Kindly find the MYSQL shells scripts in given below.
-------------------------------------------------------------------------------------------------------
#! /bin/bash
# You are free to modify and distribute this code,
# so long as you keep my name and URL in it.
# your MySQL server's name
SERVER=10.0.0.125
# directory to backup to
BACKDIR=/root/mysqlbackup/
# date format that is appended to filename
DATE=`date +'%m-%d-%Y'`
#----------------------MySQL Settings--------------------#
# your MySQL server's location (IP address is best)
HOST="10.0.0.125"
# MySQL username
USER="root"
# MySQL password
PASS="xxxxx"
# List all of the MySQL databases that you want to backup in here,
# each separated by a space
DBS="XXXX"
# set to 'y' if you want to backup all your databases. this will override
# the database selection above.
DUMPALL="n"
#----------------------Mail Settings--------------------#
# set to 'y' if you'd like to be emailed the backup (requires mutt)
MAIL=y
# email addresses to send backups to, separated by a space
EMAILS="suppport@magicalbinary.com"
SUBJECT="MySQL backup on $SERVER ($DATE)"
#----------------------FTP Settings--------------------#
# set "FTP=y" if you want to enable FTP backups
FTP=n
# FTP server settings; should be self-explanatory
FTPHOST="10.0.0.127"
FTPUSER="XXX"
FTPPASS="XXX"
# directory to backup to. if it doesn't exist, file will be uploaded to
# first logged-in directory
FTPDIR="/home/value"
#-------------------Deletion Settings-------------------#
# delete old files?
DELETE=y
# how many days of backups do you want to keep?
DAYS=6
#----------------------End of Settings------------------#
# check of the backup directory exists
# if not, create it
if [ -e $BACKDIR ]
then
echo Backups directory already exists
else
mkdir $BACKDIR
fi
if [ $DUMPALL = "y" ]
then
echo "Creating list of all your databases..."
mysql -h$HOST -u$USER -p$PASS "dlr" "dlr" > dbs_on_$SERVER.txt
# redefine list of databases to be backed up
DBS=`sed -e ':a;N;$!ba;s/\n/ /g' -e 's/Database //g' dbs_on_$SERVER.txt`
fi
echo "Backing up MySQL databases...$DBS"
read p1
for database in $DBS
do
mysqldump -h$HOST -u$USER -p$PASS $database dlr > "$BACKDIR/$SERVER-mysqlbackup-$database-$DATE.sql"
gzip -f -9 "$BACKDIR/$SERVER-mysqlbackup-$database-$DATE.sql"
# if you have the mail program 'mutt' installed on
done
# your server, this script will have mutt attach the backup
# and send it to the email addresses in $EMAILS
if [ $MAIL = "y" ]
then
BODY="Your backup is ready, please check"
ATTACH=`for file in $BACKDIR/*$DATE.sql.gz; do echo -n "-a ${file} "; done`
echo "$BODY" | mutt -s "$SUBJECT" $ATTACH $EMAILS
echo -e "Your backup has been emailed to you! \n"
fi
if [ $FTP = "y" ]
then
echo "Initiating FTP connection..."
cd $BACKDIR
ATTACH=`for file in *$DATE.sql.gz; do echo -n -e "put ${file}\n"; done`
ftp -nv <<EOF
open $FTPHOST
user $FTPUSER $FTPPASS
cd $FTPDIR
$ATTACH
quit
EOF
echo -e "FTP transfer complete! \n"
fi
if [ $DELETE = "y" ]
then
find $BACKDIR -name "*.sql.gz" -mtime $DAYS -exec rm {} \;
if [ $DAYS = "1" ]
then
echo "Yesterday's backup has been deleted."
else
echo "The backup from $DAYS days ago has been deleted."
fi
fi
echo Your backup is complete!
February 1, 2016
HÆ°á»ng dáș«n remote mysql [Äáș·t 1 code á» 1 VPS, data á» VPS khĂĄc]
káșżt ná»i code á» 1 VPS vá»i 1 data á» 1 VPS khĂĄc. CáșŁ 2 Äá»u cháșĄy VPSSIM (nginx, mysql cháșĄy mariadb vĂ PHP nhÆ° chĂșng ta ÄĂŁ biáșżt). HĂŽm nay mĂŹnh hÆ°á»ng dáș«n cĂĄc báșĄn coi nhÆ° lĂ 1 TUT cho những ai cáș§n nhĂ©.
CĂĄch lĂ m khĂĄ ÄÆĄn giáșŁn, cĂĄc báșĄn cĂł thá» ĂĄp dỄng cho má»i VPS vĂ Hosting (cĂł há» trợ tĂnh nÄng remote mysql).
1, TrÆ°á»c tiĂȘn lĂ m sao Äá» biáșżt VPS hay Host cĂł há» trợ remote mysql (trĂȘn VPS or Host chứa data thĂŽi nhĂ© cĂČn bĂȘn VPS/Host chứa code thĂŹ khĂŽng cáș§n):
Náșżu Host cho phĂ©p remote thĂŹ khi cĂĄc báșĄn áș„n vĂ o tĂȘn data cáș§n remote từ bĂȘn khĂĄc sang, cĂĄc báșĄn sáșœ tháș„y chức nÄng Add Host nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
2, CĂĄc bÆ°á»c lĂ m nhÆ° sau:
a, Náșżu cĂĄc báșĄn sá» dỄng 1 VPS chứa data.
- HĂŁy truy cáșp vĂ o phpmyadmin (trĂȘn VPS ko cĂ i phpmyadmin thĂŹ mĂŹnh cháșŻc lĂ cĂĄc báșĄn tá»± biáșżt cĂĄch lĂ m tÆ°ÆĄng tá»± ) vĂ vĂŽ pháș§n User, táșĄo 1 user má»i báș±ng cĂĄch nháș„n vĂ o Add userngay bĂȘn dÆ°á»i nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
CĂĄc mỄc khĂĄc cĂĄc báșĄn khĂŽng lĂ m gĂŹ cáșŁ rá»i áș„n Go dÆ°á»i cĂčng.
Click chá»n 1 database mĂ cĂĄc báșĄn muá»n remote rá»i áș„n Go nĂł sáșœ ÄÆ°a báșĄn Äáșżn mỄc Database-specific privileges, hĂŁy Check all rá»i áș„n Go tiáșżp:
- CĂĄc báșĄn chá» cáș§n vĂŽ Host, vĂ o Mysql Management, click vĂ o tĂȘn data muá»n remote, bĂȘn dÆ°á»i cĂĄc báșĄn Äiá»n ip của bĂȘn VPS/Host chứa code vĂ áș„n Add Host nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
nguá»n: http://diendan.w4vn.net/t/topic/28
1, TrÆ°á»c tiĂȘn lĂ m sao Äá» biáșżt VPS hay Host cĂł há» trợ remote mysql (trĂȘn VPS or Host chứa data thĂŽi nhĂ© cĂČn bĂȘn VPS/Host chứa code thĂŹ khĂŽng cáș§n):
- TrĂȘn VPS chứa data: cĂĄc báșĄn xem trong file /etc/my.cnf (file nĂ y trĂȘn VPSSIM thĂŹ nĂł á» /etc/my.cnf.d/server.cnf náșżu cĂł chứa dĂČng sau thĂŹ cĂĄc báșĄn xĂła nĂł Äi nhĂ©:
bind-address = 127.0.0.1 (xĂła dĂČng nĂ y Äi)
- TrĂȘn Hosting (á» ÄĂąy mĂŹnh vĂ dỄ lĂ Directadmin cĂČn trĂȘn CP11 thĂŹ mĂŹnh ko rĂ” lĂ cĂł nhÆ° váșy ko vĂŹ chÆ°a lĂ m trĂȘn CP11 bao giá») thĂŹ cĂĄc báșĄn áș„n vĂ o Mysql Management
Náșżu Host cho phĂ©p remote thĂŹ khi cĂĄc báșĄn áș„n vĂ o tĂȘn data cáș§n remote từ bĂȘn khĂĄc sang, cĂĄc báșĄn sáșœ tháș„y chức nÄng Add Host nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
2, CĂĄc bÆ°á»c lĂ m nhÆ° sau:
a, Náșżu cĂĄc báșĄn sá» dỄng 1 VPS chứa data.
- HĂŁy truy cáșp vĂ o phpmyadmin (trĂȘn VPS ko cĂ i phpmyadmin thĂŹ mĂŹnh cháșŻc lĂ cĂĄc báșĄn tá»± biáșżt cĂĄch lĂ m tÆ°ÆĄng tá»± ) vĂ vĂŽ pháș§n User, táșĄo 1 user má»i báș±ng cĂĄch nháș„n vĂ o Add userngay bĂȘn dÆ°á»i nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
- HĂŁy Äiá»n cĂĄc thĂŽng sá» User Name, Host, Password vĂ Re-type của password. ChĂș Ăœ mỄc Host hĂŁy chá»n Use text field sau ÄĂł Äiá»n ip của VPS/Host chứa code nhÆ° hĂŹnh dÆ°á»i:
CĂĄc mỄc khĂĄc cĂĄc báșĄn khĂŽng lĂ m gĂŹ cáșŁ rá»i áș„n Go dÆ°á»i cĂčng.
- Rá»i giá» thĂŹ hĂŁy add user ÄĂł vĂ o data mĂ cĂĄc báșĄn muá»n remote báș±ng cĂĄch quay láșĄi pháș§n User vĂ chá»n Edit Previleges :
- Sau ÄĂł click vĂ o Database:
Click chá»n 1 database mĂ cĂĄc báșĄn muá»n remote rá»i áș„n Go nĂł sáșœ ÄÆ°a báșĄn Äáșżn mỄc Database-specific privileges, hĂŁy Check all rá»i áș„n Go tiáșżp:
- Váșy lĂ xong bĂȘn VPS chứa data, qua bĂȘn VPS/Host chứa code, cĂĄc báșĄn má» file config data lĂȘn, thay vĂŹ Äiá»n localhost hĂŁy Äiá»n ip của bĂȘn VPS chứa data, thĂŽng tin khĂĄc thĂŹ cĆ©ng Äiá»n cho khá»p vá»i bĂȘn VPS chứa data.
- Rá»i táșn hÆ°á»ng thĂ nh quáșŁ thĂŽi!!!
- CĂĄc báșĄn chá» cáș§n vĂŽ Host, vĂ o Mysql Management, click vĂ o tĂȘn data muá»n remote, bĂȘn dÆ°á»i cĂĄc báșĄn Äiá»n ip của bĂȘn VPS/Host chứa code vĂ áș„n Add Host nhÆ° hĂŹnh dÆ°á»i ÄĂąy:
- Váșy lĂ xong bĂȘn VPS chứa data, qua bĂȘn VPS/Host chứa code, cĂĄc báșĄn má» file config data lĂȘn, thay vĂŹ Äiá»n localhost hĂŁy Äiá»n ip của bĂȘn Host chứa data, thĂŽng tin khĂĄc thĂŹ cĆ©ng Äiá»n cho khá»p vá»i bĂȘn Host chứa data.
nguá»n: http://diendan.w4vn.net/t/topic/28
September 7, 2015
TáșĄo crontab tá»± Äá»ng báșt láșĄi MySQL khi bá» stop trĂȘn VPS/Server
Vá»i những VPS cĂł RAM Ăt vĂ báșĄn khĂŽng rĂ” vá» config MySQL dáș«n tá»i hiá»n tÆ°á»Łng thi thoáșŁng website quĂĄ táșŁi vĂ bá» lá»i khĂŽng thá» káșżt ná»i tá»i database. BĂ i viáșżt nĂ y sáșœ hÆ°á»ng dáș«n báșĄn cĂĄch kháșŻc phỄc lá»i cháșżt MySQL vĂ táșĄo crontab tá»± Äá»ng khá»i Äá»ng láșĄi dá»ch vỄ MySQL trĂȘn VPS/Server khi website bá» hiá»n thá» lá»i tÆ°ÆĄng tá»± nhÆ° dÆ°á»i:
Error establishing a database connection
This either means that the username and password information in yourwp-config.php
file is incorrect or we can’t contact the database server atlocalhost
. This could mean your host’s database server is down.
- Are you sure you have the correct username and password?
- Are you sure that you have typed the correct hostname?
- Are you sure that the database server is running?
If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
1. Lá»nh báșt láșĄi dá»ch vỄ MySQL
TrĂȘn VPS Centos
Centos 6 (MariaDB cĆ©ng dĂčng chung lá»nh) :
1
|
service mysql start
|
Hoáș·c:
1
|
/etc/init.d/mysql start
|
Centos 7:
MySQL:
1
|
systemctl start mysql.service
|
MariaDB:
1
|
systemctl start mariadb.service
|
TrĂȘn VPS Ubuntu
1
|
/etc/init.d/mysql start
|
Hoáș·c
1
|
/etc/init.d/mysqld start
|
TĂčy trÆ°á»ng hợp cỄ thá» trĂȘn server của báșĄn lĂ mysql hay mysqld mĂ báșĄn chá»n lá»nh.
2. TáșĄo Crontab tá»± Äá»ng khá»i Äá»ng (báșt ) láșĄi MySQL
Khi service MySQL bá» stop trĂȘn VPS do quĂĄ táșŁi hoáș·c thiáșżu RAM, ta sáșœ dĂčng lá»nh trĂȘn Äá» báșt láșĄi. NgoĂ i ra, báșĄn cĂł thá» táșĄo má»t crontab tá»± Äá»ng check MySQL náșżu dá»ch vỄ nĂ y Äang bá» stop thĂŹ tá»± Äá»ng báșt láșĄi.
TrÆ°á»c tiĂȘn cáș§n táșĄo má»t file Äáș·t tĂȘn lĂ auto-start-mysql cháșłng háșĄn, ta Äáș·t file nĂ y trong folder root hoáș·c folder tĂčy Ăœ báșĄn chá»n. Sau ÄĂł chmod file nĂ y báș±ng lá»nh:
1
|
chmod +x /root/auto-start-mysql
|
Äá» thĂȘm vĂ o VPS crontab tá»± Äá»ng cháșĄy auto-start-mysql 5 phĂșt 1 láș§n ta dĂčng lá»nh:
1
|
(crontab -u root -l ; echo "*/5 * * * * /root/auto-start-mysql") | crontab -u root -
|
Ná»i dung của file auto-start-mysql nhÆ° sau:
TrĂȘn VPS Centos
Centos 6:
1
2
3
4
5
|
if [ ! "$(/sbin/service mysql status | awk 'NR==1 {print $3}')" == "running" ]; then
service mysql start
/etc/init.d/mysql restart
exit
fi
|
Centos 7:
MySQL:
1
2
3
4
|
if [ ! "$(systemctl status mysql.service | awk 'NR==3 {print $2}')" == "active" ]; then
/bin/systemctl start mysql.service
exit
fi
|
MariaDB:
1
2
3
4
|
if [ ! "$(/bin/systemctl status mariadb.service | awk 'NR==3 {print $2}')" == "active" ]; then
systemctl start mariadb.service
exit
fi
|
TrĂȘn VPS Ubuntu
MySQL:
1
2
3
4
|
if [ ! "$(service mysql status | awk 'NR==1 {print $2}')" == "start/running," ]; then
/etc/init.d/mysql start
exit
fi
|
MariaDB:
1
2
3
4
|
if [ "$(service mysql status | awk 'NR==1 {print $4}')" == "stopped." ]; then
/etc/init.d/mysql start
exit
fi
|