MySQL create user and authorization, change password

Source: Internet
Author: User
Tags mysql create mysql create user

1. Create user

CREATE  user test@localhostby'123456'; #建立的用户名为test, users with a password of 123, #localhost限制在固定地址localhost登陆

#创建远程连接用户 Create User  by ' 123456 ';

2. Authorization

GRANT Privileges  on  to ' username '@'host'

Description: Privileges-user's operation permissions, such as SELECT, INSERT, UPDATE, etc. Use all if you want to grant the permission;
DatabaseName-database name, tablename-table name, if you want to grant the user permission to operate on all databases and tables, the * representation is available *, such as *. *

For example:

 grant  insert , delete , update , select  on  test. *  to    test   " @"  localhost   " ;flush  ; 
Grant  All Privileges  on *. *  to ' test2 '@'%'by'123456'with  Grantoption;

All means to accept all actions, such as select,insert,delete ...;

*. * represents all tables below all libraries;

% on behalf of this user is allowed to log in from anywhere;

For security periods, this% can be replaced with the IP address you allow;

Then refresh the MySQL user Rights related table;

privileges ;

3. Setting and changing user passwords

SETPASSWORD for 'username'@'Host' =PASSWORD ('NewPassword') #如果是当前登陆用户SETPASSWORD=PASSWORD ("NewPassword"); #例如:SETPASSWORD for 'test2'@'%' =PASSWORD ("123456");UpdateMysql.User SetPassword=Password'New Password')where User="Phplamp" andHost="LocalHost";

update MySQL. User set Password=password (' new password 'whereUser=  and Host="localhost";

Open MySQL configuration file

Bind-address           = 127.0.0.1

Here MySQL default binding local IP, do not accept other sources, such as to remotely connect to the database, comment out this, restart MySQL;

Delete User

Delete  from User where User = ' Test '  and Host='localhost';

MySQL create user and authorization, change password

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.