Home >Database >Mysql Tutorial >How to Grant Full Database Access to a Specific MySQL User?
Full access permission settings for specific users of MySQL database
Granting full access to a specific database to a specific user in a MySQL database is a common operation in database administration. Here are the detailed steps:
First, create a new user:
<code class="language-sql">CREATE USER '用户名'@'主机名';</code>
Replace "username" with your desired username and "hostname" with the hostname to which the user is connected. If connecting from the same machine, use 'localhost'.
Then, grant this user full access to the 'dbTest' database:
<code class="language-sql">GRANT ALL PRIVILEGES ON dbTest.* TO '用户名'@'主机名' IDENTIFIED BY '密码';</code>
Command details:
GRANT
: Starts the process of granting permissions. ALL PRIVILEGES
: Grants all standard permissions, but excludes permissions using the GRANT
command. dbTest.*
: Applies permissions to all tables and objects in the 'dbTest' database. TO '用户名'@'主机名'
: Specify the user and host to which permissions are to be granted. IDENTIFIED BY '密码'
: Set the user's password. After executing the above command, you have created a new user and granted it full access to the 'dbTest' database, allowing it to perform all database operations within that database. Be sure to replace Username, Hostname, and Password with your actual values. For security reasons, it is recommended to use a strong password and grant only necessary permissions.
The above is the detailed content of How to Grant Full Database Access to a Specific MySQL User?. For more information, please follow other related articles on the PHP Chinese website!