MySQL Server 5.7 Startup Problem on FreeBSD 10.2

MySQL Server 5.7 Startup Problem on FreeBSD 10.2

I’ve just installed MySQL server 5.7 for FreeBSD 10.2 using pkg package manager. It seems the problem occur when I want to start the MySQL for the first time. This time I’m using the real VPS server and not VirtualBox. The error is : /usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql. Here is what happen to my VPS server.

Read More

MySQL Import Error : Access Denied

MySQL Import Error : Access Denied

Sometimes, an error occurred when you try to import mysql database after exporting from cpanel. I’m not searching thoroughly the cause but the problem is mysql cannot create VIEW or any STORE PROCEDURE because there is a flag command we’ve been using. Should you find this script in your VIEW or PROCEDURE :

Read More

Automatic Backup MySQL Using Python

Here is a script I create to make backup MySQL Database. Check this out.


#!/usr/bin/env python
# PyBack.py v1.1
# MySQL Backup Script
# Author Andrey Ferriyan
# Package MySQL
# SubPackage MySQL Backup Script
# License GNU/GPL
# Description Backup MySQL With Cron Method


from ftplib import FTP
import subprocess
import tarfile


# User Database, Password Database, Host Database, Port Database
USERDB='andrey'
PASSDB='blablapass'
HOSTDB='localhost'
PORTDB='3306'


# Database pada mysql yang akan di backup
ARR_DB = ['wordpress']


# Hostname / IP Address, FTPLOGIN = user FTP, FTPPASS = password FTP
FTPHOST=''
FTPLOGIN=''
FTPPASS=''


class PyBack(object):
def __init__(self):
self.USERDB=USERDB
self.PASSDB=PASSDB
self.HOSTDB=HOSTDB
self.ARR_DB=ARR_DB
self.FTPHOST=FTPHOST
self.FTPLOGIN=FTPLOGIN
self.FTPPASS=FTPPASS
self.PORTDB=PORTDB


def backup(self):
subprocess.call("/bin/rm -rf /tmp/backup",shell=True)
subprocess.call("/bin/mkdir /tmp/backup",shell=True)


for x in self.ARR_DB:
subprocess.call("mysqldump -h "+self.HOSTDB+" --databases "+x+" --user="+self.USERDB+" --password="+self.PASSDB+" -P "+self.PORTDB+" -R > /tmp/backup/"+x+".sql",shell=True)


def grouping(self):
tar = tarfile.open("/tmp/backup.tar.bz2","w:bz2")
tar.add("/tmp/backup/")
tar.close()


def transfer(self):
ftp = FTP(self.FTPHOST)
ftp.login(self.FTPLOGIN,self.FTPPASS)
ftp.storbinary("STOR /tmp/backup.tar.bz2",open("/tmp/backup.tar.bz2","rb"),1024)


if __name__ == '__main__':
pyback = PyBack()
pyback.backup()
pyback.grouping()
pyback.transfer()

Carefull with Python Syntax, especially the indentation. You have to modify the script to match with your environment. Then you can install the script in the cron system. Just try it first, don’t forget to setup a FTP Server or a local FTP Server for testing it. Have a nice try!

Read More