MySQL Conference

O’Reilly Media will be hosting the MySQL Conference in Santa Clara, California: April 12 - 15, 2010.

MySQueaL Resources

resources for mysql admins and developers who are squealing for help
site last updated:
04 mar. 2010 - 10:45:30 am


1611 hits past day

MySQL User & Security Statements

MySQL user and security statements can be used to add and remove users and to change their privileges in MySQL.

Related SQL Statements

Below are MySQL statements related to the SQL topic selected.

Privileges Statements

GRANT

This is probably the most used SQL statement for creating users and granting them privileges in MySQL. While is often used for creating users, it's main function is to set a user's privileges for a database system, specific databases, or specific tables.

REVOKE

This MySQL statement is used to easily revoke speicified privileges from a user without necessarily revoking all privileges or having to drop a user and create the user again with less privileges.

User Statements

CREATE USER

This MySQL statement is fairly straightforward: it's used to create a user, but doesn't allow privileges to be granted with it. For that, you would use the GRANT statement.

RENAME USER

If a MySQL administrator simply wants to change the user name or the host of an existing MySQL user account, but not the user account's privileges, an administrator can use this MySQL statement to do that easily.

DROP USER

If a user has no privileges at all—meaning, after you've revoke all of a user's privileges with the REVOKE statement—you can use this statement to then remove a user from the MySQL completely.

SET PASSWORD

Use this MySQL statement to change the password for a user account.

SHOW GRANTS

This MySQL statement displays the GRANT statement for a given user.

Other Statements

SHOW PRIVILEGES

This MySQL statement provides a list of privileges available, along with the context of each one (e.g., server administration) and a description. The output is not based on the user. Instead, it's a complete listing of the privileges that may be assigned to a user.

RESET

Use this MySQL statement to reset certain server settings and log files.

Related Functions

Below are MySQL functions related to the SQL topic selected.

PASSWORD( )

This MySQL function encrypts a password given as an argument. The result cannot be decrypted. This MySQL function is used for encrypting data in the password column of the user table in the mysql database.

OLD_PASSWORD( )

This MySQL function encrypts a given string based on the password encryption method used prior to version 4.1 of MySQL. The result cannot be decrypted.

AES_DECRYPT( )

This MySQL function decrypts text that was encrypted using the AES algorithm with a 128-bit key length, reversing the AES_ENCRYPT() function.

AES_ENCRYPT( )

This MySQL function encrypts a given string using the AES algorithm with a 128-bit key length. It locks the encrypted string with the password given as the second argument.

CURRENT_USER( )

This MySQL function returns the user name and the host that were given by the user for the current MySQL connection. It may not always return the same results as USER( ).

DECODE( )

This MySQL function decrypts a given string that was encrypted with a given password. See also the ENCODE( ) function.

DES_DECRYPT( )

This MySQL function decrypts text that was encrypted using the triple DES algorithm with a 128-bit key length, reversing the DES_ENCRYPT() function.

DES_ENCRYPT( )

This MySQL function returns encrypted text using the triple DES algorithm with a 128-bit key length.

ENCODE( )

This MySQL function encrypts a given string in binary format and locks it with the password. You should not use this function for the password column in the user table of the mysql database. Use PASSWORD( ) instead.

ENCRYPT( )

This MySQL function returns encrypted text using the C-language crypt function.

MD5( )

This MySQL function use an MD5 128-bit checksum to return a 32-character hash value of string from the RFC 1321 standard.

SHA( )

This MySQL function returns the Secure Hash Algorithm (SHA) 160-bit checksum for the given string. The results are a string composed of 40 hexadecimal digits.

SHA( )

This MySQL function returns the SHA 160-bit checksum for the given string.

SESSION_USER( )

This MySQL function returns the user name and the hostname for the current MySQL connection. The function takes no arguments. It's synonymous with SYSTEM_USER( ) and USER( ).

SYSTEM_USER( )

This MySQL function returns the user name and the hostname for the current MySQL connection. The function takes no arguments. It's synonymous with SESSION_USER( ) and USER( ).

USER( )

This MySQL function returns the user name and the hostname for the current MySQL connection. The function takes no arguments. It's synonymous with SESSION_USER( ) and SYSTEM_USER( ).

Return to previous page of our MySQL Documentation
MySQL columns: everywhere I look are tables and columns; life is filled with databases of information to be ordered and grouped. (Ca'Grande, Milan, Italy)

special notices

Color Highlights

When you look at SQL statements and functions on the pages for some sections of our documentation for MySQL, you may notice that some are shown in a different color (light blue at the moment). What we've done is set up a log to keep track of which pages of our documentation readers view. From there, our script every few minutes determines the most popular statements and functions and changes the colors of the links to those pages.

Need Math Examples

Although we did well in math classes all through school, we have very little experience with the Math Functions of MySQL very little. As a result, we don't have very good examples for them. If you work in science or engineering and have some ideas for easy to understand examples that we can add, please tell us.