How-to: get started with MySQL

An easy step-by-step guide to setting up a MySQL database server, along with phpMyAdmin, on Fedora, CentOS, or Ubuntu

Page 3 of 3

Once you've added those lines, save the file with Ctrl-O and exit with Ctrl-X. Now restart Apache:

# service httpd restart

On Fedora and CentOS, we also need to insert a Blowfish secret into the phpMyAdmin configuration. We can do that with nano too.

# nano /usr/share/phpMyAdmin/

(Note: You may find only a file in the phpMyAdmin directory. If so, make a copy named

Locate the line reading:

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Enter a secret between the quotes, like this:

$cfg['blowfish_secret'] = 'SDJkjshdkfjhsdf9**&^%^&%'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

The secret can be anything, preferably very random. You will not need to use this secret anywhere else; it's an internal requirement. Save the file with Ctrl-O and exit with Ctrl-X.

Now we can log in to phpMyAdmin by pointing a Web browser at the server with this URL.

http://<server IP address>/phpmyadmin

Connecting to phpMyAdminWhen you connect to phpMyAdmin, you'll be presented with a log-in dialog. By default, phpMyAdmin will be connecting to the localhost MySQL instance, not a remote instance, so this username and password needs to be either the root user or a user with sufficient privileges as noted above.

Once you've logged in, you should see a list of databases on the left, as well as configuration and management options on the right. Clicking on a database on the left will allow you to browse through the database contents, add and delete tables and data, import and export data and database schemas, and perform various other administrative tasks. Be careful that you don't perform actions that you're unsure about, such as dropping (deleting) a database.

There are a few tips you should know about phpMyAdmin to get started. First is a method of backing up or exporting a database to a file on your local system. To do this, click the database name on the left, then click the Export tab at the top. In most cases you won't need to change any of the options, but simply click the box next to the Save as file option near the bottom, select a compression type if desired, and click Go. This will cause the entire database to be exported, possibly compressed, and downloaded to your computer through the browser.

Another handy tip is the converse operation, which will import data from a backup into a new database. First, create the new database by clicking on the Home icon at the top left, then click Databases. Enter a name for the new database in the text field, select a collation if you know it, and click Create. The new database will appear in the list on the left.

Now, click the name of the new database, and click Import at the top. Click to browse for the backup file and select it, then click Go. This will automatically import the database backup into the new database.

You can also create and manage database users with phpMyAdmin. Click the Home icon in the upper left and select Privileges. You can add a user here by filling out the form and specifying the username and password. If you want the user to have global privileges, you can select them here, but if this is a user for one specific database, leave those checkboxes blank. Once the user has been created, click Privileges again, and click the Edit icon to the right of that username. Next, select a database under Database-specific privileges and grant that user whatever rights are necessary. You can use the Check All link to allow that user all privileges on the database or go more granular if needed.

Also, phpMyAdmin offers views on the server status. Click the Home icon in the upper left, click Processes to see active MySQL connections and processes, and click Status to see an exhaustive list of server traffic, query, and variable statistics. phpMyAdmin will flag certain statistics in red if they're potentially problematic -- for example, if the number of open tables is too large. Next to each variable is a brief description of the variable and sometimes a suggestion of what might be causing a problem, such as the possibility that the table cache value is too small. This is a great way to learn about the MySQL server settings and what they mean. All adjustments to these variables should be done in the my.cnf file, though some variables can be set while the server is running.

There are many more elements to proper MySQL operation, tuning, management, and administration, but this guide should get you up and running from a stock OS installation to a fully functional MySQL server with an administrative Web-based GUI. You may want to peruse the MySQL reference manuals for your server version for more information on the care and feeding of your MySQL database server.

This article, "How-to: Get started with MySQL," was originally published at Follow the latest developments in applications, data management, and open source software at Get a digest of the key stories each day in the InfoWorld Daily newsletter. For the latest business technology news, follow InfoWorld on Twitter.

Read more about applications in InfoWorld's Applications Channel.

This story, "How-to: get started with MySQL" was originally published by InfoWorld.

| 1 2 3 Page 3
ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon