Mysql adds and deletes users, adds permissions, and mysql Permissions

Source: Internet
Author: User

Mysql adds and deletes users, adds permissions, and mysql Permissions

  • Create user
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "test", password ("1234"); adds a user name named test and Password of 1234, however, this user can only log on locally. If you want to log on remotely, you can change localhost to % to indicate that any computer can log on, or change to a specific ip address to indicate that you can only log on to a specific ip address.
  • Add permissions to users
Mysql> grant all privileges on testDB. * to test @ localhost identified by '000000'; indicates that the user test has added any operations on all tables of the testDB database during local login. If you want to specify permissions, you can change all privileges to select, update, or delete or a combination of the three. If you want to specify table permissions, you can set testDB. * Changing to testDB.info indicates that operations can be performed on the info table in the testDb database. to specify the access address, you can change @ % to localhost, indicating that user test can only perform database operations locally.
  • Refresh system permission list
Mysql> flush privileges;
  • Delete a user
Mysql> Delete FROM user Where User = 'test' and Host = 'localhost ';
  • Delete accounts and permissions
Mysql> drop user username @ '% ';
  • Change User Password
Mysql> update mysql. user set password = password ('new password') where User = "test" and Host = "localhost ";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.