MySQL Database account settings

Source: Internet
Author: User

1, database backup: Pro: The database that needs to be backed up; Mypro.sql: Backup files generated by backups

C:\USERS\JFHLG>mysqldump--pro>mypro.sql 
/backup File save address as default path C:\USERS\JFHLG

c:\users\jfhlg>mysqldump -u root-p Pro>d:\mypro.sql //Backup to specified path d:\
Enter Password: ******

C:\users\jfhlg>

2, Database restore: mypdb: Accept the database of the restored files; Mypro.sql: The backup file that will be restored

Method One:
C:\USERS\JFHLG>--mydb<C:\Users\jfhlg\mypro.sql //Restore the backup file Mypro.sql to the specified database (mydb); ****** /If MyDB and Mypro have tables with the same name, the tables in MyDB will be replaced, and the tables with the same names are reserved

Method Two:
C:\Users\jfhlg\mypro.sql//restore Mypro.sql to the database in which it is currently located
Query OK, 0 rows Affected (0.00 sec)

Query OK, 0 rows Affected (0.00 sec)

···

3, create User: The newly created user needs at least INSERT permission to create another user, and the newly created user does not have any permissions;

method One:Create User 'Jingfahong'@'localhost' identified   by  '123456' ;
//create user 'jingfahong': username; 'localhost': server address; '123456': password ( the underscore can be omitted if no password is set) ; method Two:Insert intoMysql.User(Host,User, Authentication_string,ssl_cipher,x509_issuer,x509_subject)Values('localhost','JFH', Password ('123456'),"',"',"');//After using method two to create a user account, you may need to use the 'Flush Privileges' statement will not take effect until the database is refreshed

4, modify the user password:

method One: Before the login account changes (will be required to enter the original password)mysqladmin -U jinghong-pPassword 111222method Two: In the account with sufficient privileges (root user) through the following statement to modify the password of the specified account (may need to flush privileges refresh to see)update mysql.user  Set  authentication_string=password ('111222')where Host='localhost' and user ='Jinghong'; set password  for ' Jinghong ' @ ' localhost ' =password(' 111222 ');

Method Three: In the case that has been logged in and has the Change Password permission, the following statement can be used to modify its own passwordSet Password=Password('111222');

5. View the user's permissions: The newly created user needs at least SELECT permission to view information for other users (but can see the permissions they own)

 for ' JFH '@'localhost'; // View permissions

6, Grant user rights: Permission details go to: http://www.cnblogs.com/Richardzhu/p/3318595.html

Grant Select,inserton*. *  to ' JFH  'localhostwithgrantoption; // authorized to JFH users
/where * * on the left of * indicates all databases, the right * represents all data tables; * can also be replaced with the specified database and data table, indicating access to the specified libraries and tables
/additional; With GRANT option indicates that permissions can be granted to other users (permissions that can be granted cannot exceed the permissions that you own)

7, REVOKE permissions:

1to retract the specified permission for the specified user: Retract the Jinghong user's insert permission revoke insert  on*.* from 'Jinghong'@'localhost';2to recover all permissions for the specified user;revoke all privileges,grant option  from 'Jinghong'@'localhost';

MySQL Database account settings

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.