However, this fine-grained control comes at a price when you implement complex
user and privilege settings, checking these for each SQL statement you execute adds a performance penalty.
When you choose your users and their privileges, you should strive to balance control and performance. Here are some basic tips Keep it simple. If you follow the default deny philosophy, you’ll create only the users you need avoid
creating users whom you only think you might want in the future Grant the privilege as high up the hierarchy as possible. For example, if you want to grant a privilege for all tables in a database, grant it for the database instead.
Avoid using column and table privileges unless you really need them Minimize your use of the host table.
Remember, the more comparisons required
to determine permissions, the slower each query will run on your server. However, don’t compromise your security policy for the sake of performance a server that has been rendered unusable by an attack has zero performance!
Resetting Forgotten MySQL PasswordsIf you’ve forgotten a MySQL user password, you can login
to the server as the MySQLroot user and update the password manually. If you’ve forgotten the root password,
you’ll need to stop the server and restart it in a special way to allow you to change the root password.
The server is normally stopped with the mysqladmin shutdown command, but you can’t use this command if you’ve forgotten the MySQL root user password. Instead, you’ll need to use the
/etc/init.d/mysql or
/etc/init.d/mysqld script under Linux, the
MySQL_Directory/scripts/mysql.server under Linux or Mac OS X, the MySQL preferences pane under Mac OS Xor the Windows Services window to shutdown the server.
If none of these are available, you can forcibly
end or kill the server process, though this is not recommended since it can lead to data loss. You will need to have sufficient authorization to kill the server process, so you should be logged in under the same username the server is running under—for example, mysql
, or your own account if the server is running under your username—or as a superuser (system root or Windows administrator).
To kill the server under Linux or Mac OS X, you
should first determine the processidentifier (or PID) of the server process. The PID is normally stored under the server data directory in a file with the extension
.pid. You can list the contents of this file using the cat command and enclose the command in backtick symbols (
`
) to pass the output directly to the kill command
kill cat MySQL_Directory/data/your_host_name.pid`Share with your friends: