Scripting

Create a mysql trigger

This is a short description on how you can create an easy Trigger in mysql. My trigger will insert todays date when I insert a new database record. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. Some uses for […]

Read More
Linux

Enable query caching in mysql

Query caching is a way to increase the performance of mysql by caching database queries. It’s quite easy to do and only requires to edit one file, in Debian it’s called /etc/mysql/my.cnf Add the following lines in the mysqld section [mysqld] query-cache-type = 1 query-cache-size = 10M restart the mysql daemon # /etc/init.d/mysql restart Verify […]

Read More
Security

mysql_secure_installation — Improve MySQL Installation Security

This program enables you to improve the security of your MySQL installation in the following ways: You can set a password for root accounts. You can remove root accounts that are accessible from outside the local host. You can remove anonymous-user accounts. You can remove the test database, which by default can be accessed by […]

Read More
Linux

Backup mysql databases into separate files

This bach script makes separate backup files of all the databases in mysql and saves the result in the mysql_backup folder. #!/bin/bash -v USERNAME=’yourusername’ PASSWORD=’yourpassword’ HOSTNAME=’yourhostname’ BackupFolder=’/backup’ for i in $(echo ‘SHOW DATABASES;’ | mysql –user $USERNAME -p$PASSWORD -h $HOSTNAME | grep -v ‘^Database$’ ); do mysqldump –user $USERNAME -p$PASSWORD -h $HOSTNAME –opt $i > […]

Read More