Linux

Script to backup MySql database

#!/bin/bash # Shell script to backup MySql database # To backup Nysql databases file to /backup dir and later pick up by your # script. You can skip few databases from backup too. MyUSER=”SET-MYSQL-USER-NAME” # USERNAME MyPASS=”SET-PASSWORD” # PASSWORD MyHOST=”localhost” # Hostname # Linux bin paths, change this if it can’t be autodetected via which […]

Read More
Linux

MySQL Not Listening On A Public IP

By default, MySQL (on Debian) doesn’t listen on the public interface: #netstat -l tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1768/mysqld In /etc/mysql/my.cnf, comment out the bind line: #bind-address = 127.0.0.1 And restart MySQL. Then it will listen on the public interface, and you should be able to connect. #netstat -l tcp 0 0 0.0.0.0:3306 0.0.0.0:* […]

Read More
Linux

MySQL via PHP Cheat Sheet

Connect to MySQL and to the database // Connect to MySQL $connect = mysql_connect(“localhost”, “mysqluser”, “userpassword”) or die(mysql_error()); // Select the database mysql_select_db(“databasename”, $connect) or die(mysql_error()); PHP Manual Reference us2.php.net/manual/en/function.mysql-connect.php Close connection // Use the variable that was used to connect to MySQL mysql_close($connect) or die(mysql_error()); // PHP Manual Reference: us2.php.net/manual/en/function.mysql-close.php Create a database mysql_create_db(“dbname”) […]

Read More