Security When Connecting

When connecting, it is insecure to connect in the following manner:

 % mysql -uusername -ppassword 

I use this throughout this chapter for convenience, to make the password visible for purposes of the examples, but a security-conscious user should not connect in this way for the following reasons:

  • Anyone looking over your shoulder can see the password in plain text.

  • The password could be visible in the history (for example, in Unix, someone getting access to someone else's terminal could scroll through the most recent commands and be able to see the password).

  • Programs that view the system status (such as the Unix ps) could see the password in plain text.

Instead, connect by entering the password when prompted for it:

 % mysql -uroot -p Enter password:

If you need to store the password in a file, make sure it is properly secured. For example, if the password is stored in the my.cnf file in the user's home directory on a server, this file should not be readable by anyone else. The root user of the system can of course read this file. Be aware that the root user of the system is not necessarily the same as the MySQL root user. Similarly, applications often make use of a configuration file to store the database password. Make sure this is secure too.

Warning 

Never store a configuration file that contains a database password for a web application, or any password for that matter, in the web tree.

Finally, don't use the MYSQL_PWD environment variable to store your password if you desire any form of security, for similar reasons of not specifying the password on the command line. Environment variables are not secure.



Mastering MySQL 4
Mastering MySQL 4
ISBN: 0782141625
EAN: 2147483647
Year: 2003
Pages: 230
Authors: Ian Gilfillan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net