Learning Mysql


Privileges and Performance



Download 4.24 Mb.
View original pdf
Page320/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   316   317   318   319   320   321   322   323   ...   366
Learning MySQL
Privileges and Performance
MySQL’s user and privilege management gives you fine-grain control over who has access to which parts of the server and its databases, as well as what that access allows.
346 | Chapter 9:
Managing Users and Privileges

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 Passwords
If you’ve forgotten a MySQL user password, you can login to the server as the MySQL
root 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 process
identifier (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`

Download 4.24 Mb.

Share with your friends:
1   ...   316   317   318   319   320   321   322   323   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page