Recover database administrator password, user authorization, data backup and recovery

Source: Internet
Author: User
Tags install php one table administrator password create database phpmyadmin

Modify the database administrator password
# mysqladmin-hlocalhost-uroot-p Password "new

Enter Password: Current login password

Restore the database administrator password
#validate_password_policy =0
#validate_password_length =6
: Wq
#systemctl Restart Mysqld

Update Mysql.user Set

Authentication_string=password ("123QQQ") where

host= "localhost" and user= "root";
mysql> flush Privileges;
Mysql> quit
: Wq
#systemctl Restart Mysqld

User authorization
What is authorization: Add a new user who can connect on the database
The default database administrator root user has authorization permissions when they log on natively.

What is the format of the authorization command?
Grant permission list on data name to user name;

Grant permission list on data name to User name @ "Client Address";

Grant permission list on data name to User name @ "Client Address"

Identified by "password";

Grant permission list on data name to User name @ "Client Address"

Identified by "Password" with GRANT option;

How is the permission list represented?
All permissions
Select,update (Name,age)

How is the data name represented?
* * All libraries All tables
Library name. * One Library
Library name. Table Name one table

User name: Authorization when custom to have identity, is the user login is used by the name

How is the client address represented?
% all addresses
192.168.2.% Network Segment Area Host Name

Identified password used when connecting by "password"

With GRANT option has authorization permissions

Who to authorize?
Authorization to users (Web server)
Manager (Maintenance engineer)

Allows the database administrator root user to connect to the database server on a 254 host,

The connection password is abc123 after the connection has full permissions and has authorized permissions
Mysql>grant all on * * to [email protected] ""

Identified by ' abc123 ' with GRANT option;

Mysql>grant select,update (name) on Userdb.user to

Student identified by "123456";

Select User (); Displays the user name and client address of the login
Show grants; Connect users to view their access rights

Logon Test Authorization on client
#which MySQL
#yum-y Install mariadb
Grant all on bbsdb.* to [email protected] ""

Identified by "123456";
Authorization information is stored in the authorization library MySQL Library
User's existing authorized users and access rights
DB Records authorized user access to the native library
Tables_priv record authorized users ' access to native tables
Columns_priv record authorized users ' access to fields in the native table

View existing authorized users and permissions
Select User,host from Mysql.user;
Database administrator View permissions information for authorized users
Show grants for user name @ "Client Address";

Revoke user Authorization
Revoke permissions list on library name from user name @ "Client Address";

Mysql> revoke GRANT OPTION on * * FROM

' Root ' @ ' ';

mysql> revoke Delete on bbsdb.* from

' WebAdmin ' @ ' ';

Mysql> Show grants for ' WebAdmin ' @ ' ';

Mysql>update Mysql.db Set

insert_priv= "n", update_priv= "n" where db= "Bbsdb";
mysql> flush Privileges;

Mysql> Show grants for ' WebAdmin ' @ ' ';

Mysql> revoke all on bbsdb.* from

' WebAdmin ' @ ' ';

Remove an authorized user
Method One:

Mysql>delete from Mysql.user where

User= "WebAdmin" and host= "";
mysql> flush Privileges;

Method Two
Mysql> Drop user username @ "Client address";

Authorize users to log in and modify their login password
SET password=password (' New password ');

Administrator root reset the login password for authorization
For username @ ' Client address ' =password (' new password ');
Installing MySQL Graphics management tool phpMyAdmin
#yum-y Install httpd PHP
#systemctl start httpd; Systemctl Enable httpd
[Email protected] ~]# cat/var/www/html/test.php
Phpinfo ();
[Email protected] ~]#

Client Access

# TAR-ZXVF Phpmyadmin-2.11.11-all-languages.tar.gz


#mv Phpmyadmin-2.11.11-all-languages/phpmyadmin
#chown-R Apache:apache phpMyAdmin
#cd phpMyAdmin
$cfg [' blowfish_secret '] = ' plj123 ';
$cfg [' Servers '] [$i] [' host '] = ' localhost ';
: Wq
# yum-y Install Php-mysql
Mysql>create database webdb;
Mysql>grant all on webdb.* to [email protected] "localhost"

Identified by "123456";

Client Access
User WebUser
Password 123456
Data backup and Recovery
1 Why should I back up my data?
Use Backup files to recover data when data is lost or mistakenly deleted.

2 How is data backed up?
Physical backup? Backup library or table corresponding file


164 Cp-r/mydata/mysql.bak//var/lib/mysql/mysql
165 Chown-r Mysql:mysql/var/lib/mysql/mysql
166 Systemctl Restart Mysqld

Logical backup? The corresponding SQL commands are generated from the existing library tables and records at the time of backup.

SQL saved to the specified backup file

3 Data backup strategy?
Full backup back up all data (one server, one library, one table)
Differential backup backup all new generation since full backup
Incremental backup backups are all newly generated since the last backup

Full backup + differential backup
Full backup + Incremental backup

4 How to implement data backup in a build environment
Recurring Scheduled Tasks perform backup scripts

* * 1 sh/shell/

Recover database administrator password, user authorization, data backup and recovery

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: 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.