Some Linux distros now come installed with MariaDB instead MySQL. MariaDB is a fork of MySQL due to licensing fears by others about Oracle. Sun Microsystems bought MySQL and Oracle bought Sun for ownership of MySQL. Here are comparisons between MariaDB and MySQL. From InfoWorld, Dice, and SkySQL.
What do you do if your database server is down? Well, you can certainly reboot the server. That might solve the problem, but I rather restart the database first before doing something as drastic as rebooting a server. There are instances were rebooting doesn’t always solve the problem if there’s an issue with the database. Now, most open-source blogs and web applications today use MySQL as their database of choice. So, here are instructions on how to start, stop and restart MySQL on Ubuntu and Debian-based systems.
Stop MySQL database
$ sudo /etc/init.d/mysql stop
Start MySQL database
$ sudo /etc/init.d/mysql start
Restart MySQL database
$ sudo /etc/init.d/mysql restart
I want to share a database connection access problem I had last week, while working with a custom PHP script inside WordPress. I had created this WordPress Page Template containing some PHP code that needs access to the database. The problem was that the database connection for my custom script overwrote the WordPress database connection that was previously establish, causing certain parts of WordPress to not display properly.
It took me a while to figure out that it was the newer database connection of my custom PHP script that was causing the previously established WordPress database connection to disappear. Hence, certain parts of the WordPress page were not displayed. Little did I know, that the fix was quite simple. So, here’s a sample of my mysql_connect code. Prior to this line, I’ve already set the variables.
Simply add a fourth parameter called new_link and set it to TRUE.
What this does is basically telling mysql_connect to establish a new connection, while keeping the older mysql_connect connection around, in case we need to access it at a later time. It’s amazing how one little switch in a command can make a huge difference to this seemingly simple code. Anyways, adding a fourth parameter and setting it to TRUE was the solution.
If you run your own LAMP server, you might want to check out this Bash script which perform backups of the MySQL database. The neat little script can be set to run independently or as part of a cron job. All you have to do is provide the backup directory, username, password, hostname and port number.
The backup script is quite simple. It checks if the backup directory exists and creates one if it’s missing. It will then list all databases and performs a MySQL dump of each database ignoring the mysql, information_schema, and test databases. The file is formatted in gzip and then stored in the backup directory.
The backup script can be set to run every day or once a week using cron. The backup will depend on your backup requirements. I recommend testing the backup and restore process to see if it works.
There is no such thing as a perfect server, but this particular one is as close as you can get to being perfect. This tutorial will walk you through how to install the Ubuntu 10.04 LTS Server with all the services available typically that you get from ISPs and hosters.
It contains the installation of Apache web server (SSL-capable), Postfix mail server with SMTP-AUTH and TLS, BIND DNS server, Proftpd FTP server, MySQL server, Courier POP3/IMAP, Quota, Firewall, etc. It also installs the free web hosting control panel called ISPConfig2. Here’s the link to the tutorial.
Oracle promises that MySQL 5.5 will be 200% faster than its predecessor. From H-Online:
Oracle presented a beta of what it called a “much faster” MySQL at the O’Reilly MySQL Conference and insists it will be continuing to invest in the open source database. Oracle’s Chief Corporate Architect, Edward Screven, presented the beta version of MySQL 5.5 which will now use InnoDB as its default storage engine, saying that the switch offers a 200% performance improvement and over ten times faster recovery times. He assured the audience that despite the switch to Oracle’s InnoDB, Oracle will be maintaining the pluggable storage engine architecture and that the company would continue to ship the same code base in the community and enterprise editions.
Screven said Oracle’s plan for MySQL was to keep it as a slim, easy-to-administer database and that it would be investing to make MySQL compete more effectively with Microsoft’s SQL Server. He noted that more customers deploy MySQL on Windows than on any other platform. In an interview with eWeek before the presentation, Screven also confirmed that MySQL’s Falcon storage engine was no longer being developed. “Falcon was Sun’s, or actually really MySQL AB’s…response to Oracle buying InnoDB” he said, “Now that we’ve brought the teams together, Falcon doesn’t have a place in the world”. Oracle’s future plans include making it easier to migrate data between MySQL and Oracle databases and adding Oracle features such as Secure Backup, Enterprise Manager and Audit Vault to MySQL.
A number of WordPress blogs hosted at Network Solutions were hacked according to ZDNet. A malicious hacker was able to create a script that scanned for WordPress config files which contain MySQL database credentials in plain text.
WordPress config files should only be read by Apache only with permissions of 750. Most users have their permissions set to 755. WordPress users should set their permissions to 750 to avoid from being hacked.
Another way of protecting WordPress config files is to use .htaccess. Add the following code to your .htaccess file.
# protect wpconfig.php <files wp-config.php> order allow,deny deny from all </files>