Securing MySQL

Securing MySQL

Due to differing needs and requirements this is difficult to answer except on a case by case basis. The MySQL website has a section regarding general security of a MySQL database available here: http://dev.mysql.com/doc/refman/5.0/en/security.html

Additionally some good practices are:

  1. Verify your root MySQL account password is set
  2. the test account and database that were created during the initial installation
    • Login to mysql as root, from the command prompt “shell> mysql –u root –p mysql” and enter the password when prompted
    • mysql> drop database test;
    • mysql> use mysql;
    • mysql> delete from user where user='test';
    • mysql> delete from user where user='';
    • mysql> flush privileges;
  3. Make sure that each account has a password set
  4. Do not grant global privileges unnecessarily
  5. Avoid using wildcards in the hostname value associated with accounts
  6. Periodically review users and databases that are setup in MySQL
  7. Do not use passwords on the command line. From the command line you can login to MySQL using "shell> mysql –u root –password=somepassword mysql" the problem with this is anyone on the server could view your password with a simple process list command "shell> ps". The correct usage would be: "shell> mysql –u root –p mysql", from this MySQL will prompt your for your password and it will not show up in the process list as plain text.


Note: There are many excellent articles available on the web for MySQL security. Go to your search engine of choice and search “securing mysql” and you should have reading for weeks.

    • Related Articles

    • MySQL Optimization / Repair Information

      How MySQL Uses Memory This page lists some of the ways that the mysqld server uses memory, and associated mysqld variable names Memory Use MySQL 5.0 Memory Use MySQL 4.1 MySQL Optimization which covers: - Optimization Overview - Optimizing SELECT and ...
    • How to install Mysql

      How to install Mysql Via RPM : Please check the following link and get RPM http://httpupdate.cpanel.net/mysqlinstall/ in above list (not rpm) click on the version for which you want to install mysql than click on the operation system than on the ...
    • Mysql Basic Commands

      [mysql dir]/bin/mysql -h hostname -u root -p Create a database on the sql server. create database [databasename]; List all databases on the sql server. show databases; Switch to a database. use [db name]; To see all the tables in the db. show tables; ...
    • What is my root password for MySQL?

      If the server was auto provisioned with MySQL then the root password is the same as the server root password. If you have Plesk auto provisioned on your server, then use "admin" and the admin password for Plesk. If you installed MySQL through source, ...
    • Repairing MySQL tables that will not open

      This should be handled on a case by case basis, but if you are using the default MySQL table type of MyISAM (which is the default storage engine unless changed or specified differently) here are a few options: The myisamchk utility can be run from a ...