Security
Set theroot password
. The default install of MySQL leaves the root password blank. So the first step you take after you install MySQL should be this one:shell> mysql -u root mysqlmysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';mysql> FLUSH PRIVILEGES;
AccessControlLists
. MySQL uses Access Control Lists (ACLs) for all connections, queries, and other operations that a user may attempt to perform. The ACLs are composed of tables which are used to determine privilege.MySQL access control involves two stages:
Stage 1 Connection Verification
: The server checks whether you are even allowed to connect.
Stage 2 Request Verification
: Assuming you can connect, the server checks each request you issue to see whether you have sufficient privileges to perform it.The server uses theuser,db, andhosttables in the mysql database at both stages of access control. For the second stage of access control, the server may, if the request involves
tables, additionally consult thetables_privandcolumns_privtables.
A description of these tables can be seen below:
mysql> DESCRIBEuser;+-----------------+-----------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------------+-----------------+------+-----+---------+-------+| Host | char(60) binary | | PRI | | || User | char(16) binary | | PRI | | || Password | char(16) binary | | | | || Select_priv | enum('N','Y') | | | N | || Insert_priv | enum('N','Y') | | | N | || Update_priv | enum('N','Y') | | | N | || Delete_priv | enum('N','Y') | | | N | || Create_priv | enum('N','Y') | | | N | || Drop_priv | enum('N','Y') | | | N | || Reload_priv | enum('N','Y') | | | N | || Shutdown_priv | enum('N','Y') | | | N | || Process_priv | enum('N','Y') | | | N | || File_priv | enum('N','Y') | | | N | || Grant_priv | enum('N','Y') | | | N | || References_priv | enum('N','Y') | | | N | || Index_priv | enum('N','Y') | | | N | || Alter_priv | enum('N','Y') | | | N | |+-----------------+-----------------+------+-----+---------+-------+mysql> DESCRIBEdb;+-----------------+-----------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------------+-----------------+------+-----+---------+-------+| Host | char(60) binary | | PRI | | || Db | char(64) binary | | PRI | | || User | char(16) binary | | PRI | | || Select_priv | enum('N','Y') | | | N | || Insert_priv | enum('N','Y') | | | N | || Update_priv | enum('N','Y') | | | N | || Delete_priv | enum('N','Y') | | | N | || Create_priv | enum('N','Y') | | | N | || Drop_priv | enum('N','Y') | | | N | || Grant_priv | enum('N','Y') | | | N | || References_priv | enum('N','Y') | | | N | || Index_priv | enum('N','Y') | | | N | || Alter_priv | enum('N','Y') | | | N | |+-----------------+-----------------+------+-----+---------+-------+mysql> DESCRIBEhost;+-----------------+-----------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------------+-----------------+------+-----+---------+-------+| Host | char(60) binary | | PRI | | || Db | char(64) binary | | PRI | | || Select_priv | enum('N','Y') | | | N | || Insert_priv | enum('N','Y') | | | N | || Update_priv | enum('N','Y') | | | N | || Delete_priv | enum('N','Y') | | | N | || Create_priv | enum('N','Y') | | | N | || Drop_priv | enum('N','Y') | | | N | || Grant_priv | enum('N','Y') | | | N | || References_priv | enum('N','Y') | | | N | || Index_priv | enum('N','Y') | | | N | || Alter_priv | enum('N','Y') | | | N | |+-----------------+-----------------+------+-----+---------+-------+mysql> DESCRIBEcolumns_priv;+-------------+----------------------------------------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------------+----------------------------------------------+------+-----+---------+-------+| Host | char(60) binary | | PRI | | || Db | char(64) binary | | PRI | | || User | char(16) binary | | PRI | | || Table_name | char(64) binary | | PRI | | || Column_name | char(64) binary | | PRI | | || Timestamp | timestamp(14) | YES | | NULL | || Column_priv | set('Select','Insert','Update','References') | | | | |+-------------+----------------------------------------------+------+-----+---------+-------+mysql> DESCRIBEtables_priv;+-------------+-----------------------------------------------------------------------------------------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |
Add a Comment