Beginning PostgreSQL

Posted 440 days ago | 0 Comments

As a MySQL user for a number of years I needed a translation tutorial from MySQL to PostgreSQL. So to get started on CentOS: Installation yum install postgresql-server If you also want the phpPgAdmin WUI: yum install phpPgAdmin php-pgsql httpd Create the configuration file and initialise the database: cp /usr/share/pgsql/postgresql.conf.sample /var/lib/pgsql/data/postgresql.conf /etc/init.d/postgresql initdb Make changes [...]

Continue Reading

LAMP Performance

Posted 456 days ago | 0 Comments

The following scripts can help in determining good values for Apache and MySQL configurations based on the amount of memory available: MySQL Tuner Apache Tuner Apache Buddy The following will giveĀ  a list of Apache Modules loaded: apachectl -t -D DUMP_MODULES The following will give the memory usage of Apache: #!/bin/sh # apache_mem.sh # Calculate [...]

Continue Reading

LAMP on Ubuntu

Posted 619 days ago | 0 Comments

There are several different commands that can be used to install Apache and MySQL services with PHP support: sudo apt-get install tasksel && sudo tasksel sudo apt-get install lamp-server^ sudo apt-get install apache2 libapache2-mod-php5 php5 php5-cli php5-mysql php5-gd php5-mcrypt php5-curl mysql-client mysql-server libmysqlclient15-dev phpmyadmin   For number two the carat at the end is important.

Continue Reading

MySQL Proxy

Posted 868 days ago | 2 Comments

Today I wanted to create a straight-forward MySQL Proxy service which would forward MySQL queries from a development machine to another live server which was running MySQL. The aim was to allow people on the development machine to use the same connection string as on the live server, specifying the MySQL host as localhost but [...]

Continue Reading

MySQL query output to text or CSV

Posted 876 days ago | 0 Comments

I needed to output the results of a MySQL query today for further analysis and found the answer here. For future reference… SELECT * FROM errors WHERE mailfrom LIKE ‘a.n.other%’ INTO OUTFILE ‘/tmp/a.n.other.txt’ FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’; It is also possible to enclose the fields with quotes using: ENCLOSED BY ‘”‘

Continue Reading

MySQL: Too Many Connections

Posted 901 days ago | 0 Comments

On a shared server with MySQL and Apache the MySQL server was periodically disallowing connections as there were already too many connections. The default is 150+1 so I added the following to /etc/my.cnf max_connections=200 To increase the maximum number of connections to 200+1

Continue Reading

Set MySQL to Read-Only

Posted 1254 days ago | 0 Comments

For a backup server which we may want to run as read-only for short maintenance periods the following may be useful.Method 1: Global read_onlyLogin to MySQL and set the read_only setting to true: mysql -u root -pset GLOBAL read_only = true; To unset this run: set GLOBAL read_only = false; Method 2: Read LockAnother method [...]

Continue Reading

mysqldump

Posted 1331 days ago | 0 Comments

Basic Usage: mysqldump -u root -pSECRET –quote-names –databasesĀ  mydatabasename > mydatabasename.sql If find it best to include the –databases switch as this will add the ‘DROP DATABASE’ and ‘CREATE DATABASE’ statements when restoring – proceed carefully.Quote Names:Quoting the file names can be an insurance against users who may have created field names with spaces in [...]

Continue Reading

MySQL 4 to MySQL 5 Character Sets and Collation

Posted 1381 days ago | 0 Comments

Moving from MySQL 4 to MySQL 5 caused a few issues on Joomla websites. The problems stem from MySQL 4 using latin1 swedish as default but some applications like Joomla want utf8 so:1. Re-export the database (it is Ok to do this from the existing MySQL 5 database): mysqldump -u username -p –default-character-set=latin1 –compatible=mysql40 dbname [...]

Continue Reading

MySQL 4 to MySQL 5 Character Sets and Collation

Posted 1406 days ago | 0 Comments

Moving from MySQL 4 to MySQL 5 caused a few issues on Joomla websites. The problems stem from MySQL 4 using latin1 swedish as default but some applications like Joomla want utf8 so:1. Re-export the database (it is Ok to do this from the existing MySQL 5 database): mysqldump -u username -p –default-character-set=latin1 –compatible=mysql40 dbname [...]

Continue Reading