The basic operation of MySQL

Source: Internet
Author: User

1. Create a new user

Login mysql@>mysql-u root-p@> Password//create user mysql> insert into Mysql.user (Host,user,password) VALUES ("localhost", " Phplamp ", Password (" 1234 "));//Refresh the System permissions table Mysql>flush privileges; This creates a user named: Phplamp  Password: 1234  . Then log in. Ps:2 Point Pit, 1, there may be anonymous users in the new database that need to be deleted or will not be logged in correctly. reference:http://stackoverflow.com/questions/10299148/ MYSQL-ERROR-1045-28000-ACCESS-DENIED-FOR-USER-BILLLOCALHOST-USING-PASSW;2 values in the password to use the password package, otherwise you can not log in normally. (not yet know why) mysql>exit;@>mysql-u phplamp-p@> Enter password mysql> login successful

2 User Authorization

Log in to MySQL (with root privileges). I am logged in as root.//must be logged in by the administrator of the root authority only. @>mysql-u root-p@> Password//First create a database for the user (phplampdb) mysql>create db phplampdb;// Authorizes the Phplamp user to have all the permissions of the Phplamp database. >grant all privileges in phplampdb.* to [e-mail protected] identified by ' 1234 ';//Refresh System Permissions Table// Actions such as authorization to refresh the permissions table or restart the MySQL server Mysql>flush privileges;mysql> Other actions/* If you want to specify partial permissions to a user, you can write: Mysql>grant Select , update on phplampdb.* to [e-mail protected] identified by ' 1234 ';//Refresh the System permissions table. Mysql>flush privileges;*/

Reduce user Rights
>revoke alter,select on books.* from test;
Revoke all permissions
>revoke all on books.* from test

3 Deleting a user

@>mysql-u root-p@> password mysql>delete from mysql.user WHERE user= "Phplamp" and host= "localhost"; mysql>flush privileges;

4 Modifying user passwords

@>mysql-u root-p@> password mysql>update mysql.user set Password=password (' New password ') where user= "Phplamp" and Host= " localhost "; mysql>flush privileges;

  

The basic operation of MySQL

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.