MySQL creates a remote user and authorizes

Source: Internet
Author: User

Today needs to test the system function locally, because there is no database, you need to connect the remote database in the program;

SSH login to the remote server, with the root of the database to see the situation;

Mysql> SelectHost,User, Password fromMysql.User;+----------------+------------------+-------------------------------------------+|Host| User             |Password|+----------------+------------------+-------------------------------------------+|localhost|Root| *836e233974ebe6ea32f95f890a91363f8427f78b||Iz94926clkiz|Root| *836e233974ebe6ea32f95f890a91363f8427f78b|| 127.0.0.1      |Root| *836e233974ebe6ea32f95f890a91363f8427f78b||::1            |Root| *836e233974ebe6ea32f95f890a91363f8427f78b||localhost|Debian-Sys-Maint| *1460ed3535abdbb887f9e5f57f40a2354610cdf3|+----------------+------------------+-------------------------------------------+5Rowsinch Set(0.00Sec

A total of 5 MySQL accounts, the host column can be seen, these accounts are only support server native connection, now we create a remote user;

Create User  by ' 123456 ';
+----------------+------------------+-------------------------------------------+|Host| User             |Password|+----------------+------------------+-------------------------------------------+|localhost|Root| *836e283974ebe6ea32f95f890a91363f8427f78b||Iz949s6clkiz|Root| *836e283974ebe6ea32f95f890a91363f8427f78b|| 127.0.0.1      |Root| *836e283974ebe6ea32f95f890a91363f8427f78b||::1            |Root| *836e283974ebe6ea32f95f890a91363f8427f78b||localhost|Debian-Sys-Maint| *1460ed35e5abdbb887f9e5f57f40a2354610cdf3|| %              |Test| *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9|+----------------+------------------+-------------------------------------------+6Rowsinch Set(0.00Sec

Create completed, in the program inside the connection found or no permissions, just now we just created the user, has not assigned permission to this user;

Grant  All Privileges  on *. *  to ' Test '@'%'by'123456'with  Grantoption;

All means to accept all actions, such as select,insert,delete ...; *. * represents all tables below all libraries;% is allowed to log in from anywhere; for security periods, this percentage can be replaced with the IP address you allow;

Then refresh the MySQL user Rights related table;

privileges ;

I thought it was done, and so on, the program is still not even up, or access deny;

The port is not 3306, open the MySQL configuration file, is the default of 3306, and then looked down, found a key place;

Bind-address           =127.0.  0.1

Here MySQL default binding local IP, do not accept other sources; Comment out, restart MySQL all OK;

There are also two common operations;

Modify the specified user password

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

Delete User

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

MySQL creates a remote user and authorizes

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.