Display MySQL Variables with a PHP Tool

March 13th, 2008

This article is about a tool that can be used to show the values of all your MySQL server system variables through a web browser. It can work even if you don’t have administrative access to your server. This tool can be used to help diagnose the problem described in one of my other articles.

Installing the Tool

  1. Download show-mysql-vars.zip
  2. Unzip the show-mysql-vars.php file from the zip archive.
  3. If you have WordPress, upload the show-mysql-vars.php file to the same directory as your wp-config.php file (root WordPress directory)
    • This is helpful because the script will get your MySQL username and password from the wp-config.php file.
  4. If you don’t have WordPress, then upload it to any directory in your webserver that can execute PHP files.

Executing the Tool

  1. Open the file in your browser, i.e. http://www.example.com/wp/show-mysql-vars.php
  2. If you installed it in the same directory as your wp-config.php file, the MySQL variables should be displayed for you.
  3. If you don’t have WordPress or a wp-config.php file, you’ll be asked for your MySQL username and password. Enter that in and click “Submit”.
  4. I recommend to remove this PHP file from your server after you use it to increase security.

How it Works

The script essentially executes the MySQL query “show variables”, and prints out the results. It also executes the MySQL query “show status” and prints out those results too.

Alternatives

There are several alternative methods besides this PHP script:

  1. Use the phpMyAdmin utility if it is available to you.
    • There should be a link in that utility titled “Show MySQL system variables”.
  2. If you have ssh access, you can use the “mysql” command.
    shell prompt> mysql -u username -ppassword
    mysql> show variables;
  3. If you have ssh access, you can use the “mysqladmin” command.
    shell prompt> mysqladmin -u username -ppassword variables

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.