
Over the course of the past year, we have covered many dedicated server maintenance issues, particularly for servers running Linux. In no particular order, here is a list of some of the more important tips you should remember when taking care of your server.
1. When possible, rely on the distribution updates and repositories. Only add third-party software when absolutely necessary.
2. Periodically run fsck to check the file system.
3. Monitor system and service logs.
4. Disable unused services.
5. Periodically optimize MySQL databases.
6. Monitor CPU and RAM usage.
7. Optimize RAM and swap usage.
8. On larger servers, run the database server on a separate machine, optimize the servers for scalability, and consider using a CDN (Content Delivery Network).
Photo Source: Flickr

Question: My database server is timing out because MySQL seems to hang once it has used up 4GB of RAM, even though the server is equipped with 6GB. How can I make MySQL take advantage of the full 6GB available?
Answer: If your current server setup involves a 32-bit architecture or even just a 32-bit version of your operating system, the short answer is: you cannot. By design MySQL will not be able to use more than 4GB unless it is running on a 64-bit OS.
If you are running Linux, type ” uname -m ” from the command line to see whether or not you are using a 64-bit version. If you know for a fact that your server actually has 64-bit processors, you can reinstall Linux with a 64-bit kernel.
The other less-drastic measure you may be able to take is to install a PAE (Physical Address Extension) kernel, which will allow your server to access physical address space larger than 4 GB. Some distributions, such as CentOS offer PAE kernel packages that you can easily install.
Source: Webhostingtalk.com
Photo: Flickr
Continue reading: How to Increase MySQL Memory Usage Above 4GB

When MySQL works correctly, it can be a thing of beauty, but when something goes wrong, it can drive you mad. Here are a few things you can do to troubleshoot connection problems:
1. Make sure your username and password are correct.
2. Double-check the hostname. Although “localhost” works on most servers, it may not on yours.
3. Test the connection string (if you wrote the code yourself). You may have a simple typo.
4. If you have your own server, check the mysql server to see if it is running and running without errors.
5. Does the database you are trying to connect to actually exist? Sometimes automatic database creation fails, and you are left wondering why you cannot connect to it.
6. If you can connect locally but cannot connect remotely, check your firewall settings to see if port 3306 (or whichever port you use for mysql) is open.
7. Finally, be sure your mysql user has the necessary privileges to perform whatever task you are trying to accomplish.
Photo Source: Flickr
As I mentioned in a previous MySQL post, knowing how to quickly perform database tasks from the command line is a good idea if you are a Linux system administrator. Sometimes, it is the easier way to get things done, especially if you are helping another user and need root access to his or her database.
To delete a table, first login to MySQL:
mysql -u root -p
Enter your password and then switch to the database you want to edit by typing the following at the mysql> prompt:
mysql> use [db name];
Finally, drop the table:
mysql> drop table [table name];
Replace [table name] with the actual name of the table you want to remove.
To remove a row, type:
mysql> DELETE from [table name] where [field name] = 'whatever';
When you are finished, type “quit” to exit.

With web-based control panels and web software like phpMyAdmin, you have numerous options available for searching a MySQL Database. If the need should ever arise where those tools are not available, however, it is a good idea to know how to search a database from the command line.
To search MySQL from the command line, you need to log in to MySQL and perform a query.
Login as root:
mysql -u root -p
You should get a prompt like “mysql>”
To do a basic search, use the SELECT command. For example, to search for all records with the title of “Sales” that also have the number “44″, enter:
mysql> SELECT * FROM [table name] WHERE title = "Sales" AND number = '44';
You can perform similar queries on any tables in your database. For a more in-depth guide to queries, consult the MySQL documentation.
Photo Source: Wikimedia Commons
1. Query cache - On most servers, there are certain MySQL queries that you and/or your scripts will run more often than others. In fact, you may run the same query hundreds or even thousands of times in a single day. The query_cache setting will save the most used queries in memory for quick access
query_cache_limit=1M
query_cache_size=32M (32MB for every 1GB of RAM)
query_cache_type=1
2. Key buffer size - This refers to the size of buffers used for indexes. A larger buffer will result in faster SQL response time when a command is issued. The key_buffer_size should be at least 1/4 but no more than 1/2 of the RAM size of the server.
key_buffer=256M (128MB for every 1GB of RAM)
3. Table cache - Just like MySQL can cache queries, it can also cache tables. If you think about how often a database table would be accessed, especially when using content management systems and web applications, this only makes sense. You can adjust this according to your memory.
table_cache=1500
Next week, we will cover more MySQL optimization tips.
Source: linuxstuffs
If you are running a dedicated server, optimization is very important to maximize speed, efficiency, and save time and energy. We have already looked at ways to optimize Apache web server, but many dynamic websites also use databases that hold the data for their dynamic web applications.
You can accomplish basic optimization of database tables from within your web-based control panel or in phpMyAdmin. You should do this routinely. But there are also ways you can optimize the server itself to serve databases faster and more securely. Over the remainder of this week, I will show you a few tips to optimize your MySQL server. Today, I will just point you to the right file.
To begin configuring your MySQL server, you will need to locate the configuration file. This will differ, depending on your operating system and even from one Linux distribution to another. Most commonly, it will be in a directory like /etc/mysql, and the file will be called my.cnf. You will need to edit it as root:
# nano /etc/mysql/my.cnf
Tomorrow, we will start to plow through this file for optimization tweaks.

Joomla is a powerful free and open source content management system. It has become very popular, and many web hosting provider offer instant installer scripts that can automatically install Joomla onto a customer’s website. In certain, situations, however, you may prefer to install Joomla yourself. When you do, there are certain security issues you should know.
1. Delete the “install” directory. Joomla tells you to do this, and if you forget, the results can horrific.
2. Chmod configuration.php to at least 644. No one should be able to access your configuration.php file. The only reason to even leave it as 644 and not 600 is that some web servers on shared hosts require PHP files to be readable by the web server, which is a different user than the site owner.
3. Backup early and often - Create backups of Joomla’s MySQL database. If anything ever does go wrong, you will have a backup.
4. Install mod_security - ModSecurity is an application firewall designed for web applications like Joomla. It will protect you where a network firewall cannot.
5. Secure your database - Setup Joomla to access the database with a user with limited privileges, and make sure the password is not easy to guess.
There are many more security issues you should consider. Over the coming days, I will highlight some of them. Hopefully, they will help you keep your Joomla installation stable and secure.
Monday, the database giant, Oracle, announced the release of MySQL Enterprise. In addition to the standard, freely available database software, this new packaged version of MySQL will include comprehensive support and monitoring tools. The primary tool available with this release is MySQL Monitor 2.2, which monitors performance and security. Other important tools include the Query Analyzer and MySQL Connector Plugins.
“DBAs and developers need solutions that help them manage their MySQL servers efficiently and allow them to identify performance issues before they become expensive, time-consuming problems,” said Tomas Ulin, director, MySQL Development, Oracle.
MySQL is one of the most widely-used database servers on the Web, and most web hosting providers offer it. While the underlying code for the database software is free and open source, there is also a commercially licensed version. MySQL was owned by Sun Microsystems until Oracle recently bought Sun and all of its software products.
Source: MarketWatch
In the web hosting world, certain database software is commonplace. Most system administrators, even the new ones, have heard of MySQL, MSSQL, and/or PostgreSQL. Using SQL databases typically requires a database server to be running on the system. MySQL, for example, runs as a service in Linux called mysqld, or something similar. An alternative to running these types of services is to use SQLite.
Because it does not run via a sever, SQLite does not require the configuration and maintenance of other database systems. As a result, it is considered light and easy to use. Rather than running on a server, the database code is linked directly with the software using it. The library itself is small and can be installed in smaller installations.
According to their website, SQLite is the most often deployed database engine used in many web applications. It is free and open source, without a license, released into the public domain. You can download the libraries at the SQLite website.
Selecting a MySQL database table with a PHP document is a quick way to get certain output onto a web page with very little coding or effort. You may want nothing more than a simple printout of the database table or something more complex like a full web application.
Regardless of the scenario, selecting multiple database tables in the same query is a little more tricky. Here is a syntax that worked for me. First connect to your database the way you normally would, then enter your query like this:
$result = mysql_query("SELECT * FROM table1, table2 ");
Replace “table1″ and “table2″ with the actual names of your tables. Next, you can show rows from both tables, but if any of the rows have the same names in both tables, you will have to specify them specifically in the query.
Finally, display the results however you like:
while($row = mysql_fetch_array($result))
{
echo "<div id='corn'> ";
echo $row['corn'];
echo "</div> <div id='wheat'> ";
echo $row['wheat'];
echo "</div> ";
For more information on MySQL Select, see w3schools.com
Photo: Wikimedia Commons
Continue reading: PHP: How to Select Multiple Database Tables

After you create a MySQL database, the next thing you will most likely want to do is to fill it with data. To do that, you need to setup tables. If you are installing a content management system or other type of script with an installer, it will probably create the tables for you. If that is not the case, you must create the tables yourself. While creating them from the command line is not terribly difficult, using the phpMyAdmin web interface is probably the easiest method.
To create a new table, follow these steps:
1. Login to your phpMyAdmin installation either through your control panel or directly.
2. On the left, click the database you want to manipulate.
3. At the bottom, underneath the current tables, find “Create new table on database” and enter the name and number of fields each row will have.
4. Enter the field names (each row will have a name assigned to it)
5. Select the data type. The default INT is for integer (i.e. a number). You can see a complete lists of data types on the mysql website
6. Select a maximum length or leave it blank
7. Set the type of collation, essentially the encoding, such as UTF-8.
8. When you have all of the information inputed, scroll to the bottom and click “Save”.
With that, you are all finished with your first table.