![]() In this case, you should inform the user first. If you drop a currently connected user, the user can operate as normal until the next login. Suppose that you want to drop the user the user account is still connected to MySQL Server. ![]() ( 'John', 'Doe') Code language: SQL (Structured Query Language) ( sql ) Seventh, insert a row into the persons table: insert into persons(firstname, lastname) Sixth, select the people database: use people Code language: SQL (Structured Query Language) ( sql ) Type the password for the user account alice and press the Enter key: Enter password: ************ Code language: SQL (Structured Query Language) ( sql ) ) Code language: SQL (Structured Query Language) ( sql )įourth, grant all privileges on the people database to the account user alice: grant all privileges on people.* to Code language: SQL (Structured Query Language) ( sql )įifth, launch another session and connect to the database using the user mysql -u alice -p Code language: SQL (Structured Query Language) ( sql ) Third, create a new table persons in the people database: create table persons( Second, select the people database: use people Code language: SQL (Structured Query Language) ( sql ) Second, show all the users: select user, host from er Code language: SQL (Structured Query Language) ( sql )Ħ rows in set ( 0.00 sec) Code language: SQL (Structured Query Language) ( sql ) 3) Using the DROP USER statement to remove a connected userįirst, create a new database called people: create database people Code language: SQL (Structured Query Language) ( sql ) 2) Using the DROP USER statement to remove multiple user accountsįirst, remove two user accounts remote using the following statement: drop user remote Code language: SQL (Structured Query Language) ( sql ) The user account has been removed successfully. ![]() Output: + -+-+Ĩ rows in set ( 0.00 sec) Code language: SQL (Structured Query Language) ( sql ) Here is the current user list: + -+-+ĩ rows in set ( 0.00 sec) Code language: SQL (Structured Query Language) ( sql )įourth, drop the user by using the DROP USER statement: drop user Code language: SQL (Structured Query Language) ( sql )įifth, show all users again: select user, er Code language: SQL (Structured Query Language) ( sql ) Third, show users from the MySQL Server: select user, Second, create four account users accounts remote, and create user identified by 'Secure1Pass!' Code language: SQL (Structured Query Language) ( sql ) Type the password for the root user and press Enter: Enter password: ******** Code language: SQL (Structured Query Language) ( sql ) 1) Using MySQL DROP USER statement to drop a user exampleįirst, connect to the MySQL Server using the root account: mysql -u root -p Code language: SQL (Structured Query Language) ( sql ) Let’s take some examples of dropping users. Code language: SQL (Structured Query Language) ( sql )īesides removing the user account, the DROP USER statement also removes all privileges of the user from all grant tables. In MySQL 5.7.8+, you can use the IF EXISTS clause to conditionally drop a user only if it exists: DROP USER account_name. If you remove a user account that doesn’t exist, MySQL will issue an error. Code language: SQL (Structured Query Language) ( sql ) If you want to remove multiple user accounts at once, you specify a list of comma-separated user accounts in the DROP USER clause: DROP USER account_name. In this syntax, you specify the name of the user account that you want to remove after the DROP USER keywords.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |