MySQL database management database ---

- Create a user, specify the clear text password
create user 'rose' @ 'localhost ' identified by 'rosepwd';

- Check whether the user was created successfully
select user, host from mysql.user;

- Create a user without password
create user 'rose01' @ 'localhost ';

select user,host from mysql.user;

- view the password hash values
select password ( 'rosepwd');

- Create a user, using the hash value of a password
create user 'rose02' @ 'localhost ' identified by password '* 15151B36B8E49FD6A6222C4AF15758661CFCE654';

- Create a user and grant the user's query, update privileges to all database tables
grant select, update on * * to 'testuser' @ 'localhost' identified by 'testpwd';.

select user,host from mysql.user;

- Delete User
drop user 'testuser' @ 'localhost ';

select user,host from mysql.user;

-- 删除用户
delete from mysql.user where user = 'rose02'and host='localhost';

select user,host from mysql.user;

- Grant rose the user to insert, query table book library all permissions
grant insert, select on book * to 'rose' @ 'localhost';.

- Refresh system permissions table
flush privileges;

- Grant rose01 apply to all library users all the permissions on all tables
grant all privileges on * * to ' rose01' @ 'localhost';.

- view a user's permissions information
show grants for 'rose' @ ' localhost';

show grants for 'rose01'@'localhost';

- recycling rose to insert user role permissions book library all tables
revoke insert on book * from 'rose ' @ 'localhost';.

flush privileges;

show grants for 'rose'@'localhost';

- view the log file path
show variables like 'log_error';

- create a new log table
flush logs;

- create a new log table
mysqladmin -uroot -p flush-logs

- Backup book library
mysqldump -uroot -p book> C: \ mysqlbackup \ book_20180120.sql

- Backup book library readerinfo table
mysqldump -uroot -p book readerinfo> C: \ mysqlbackup \ book_readerinfo_20180120.sql

- Backup and mytest book library
mysqldump -uroot -p --databases book mytest> C : \ mysqlbackup \ book_mytest_20180120.sql

- Back up all databases
mysqldump -uroot -p --all-databases> C : \ mysqlbackup \ dball_20180120.sql

- recovery readerinfo under the table book library
mysql -uroot -p book <C: \ mysqlbackup \ book_readerinfo_20180120.sql

- recovery readerinfo under the table book library
use book;
Source C: \ mysqlbackup \ book_readerinfo_20180120.sql

- Use the select ... into outfile export data readerinfo table to readerinfo.txt this file
select * from book.readerinfo into outfile 'C : / ProgramData / MySQL / MySQL Server 5.7 / Uploads / readerinfo.txt';

- Use the select ... into outfile export data readerinfo table to readerinfo.txt this file and set the export file format
select * from book.readerinfo into outfile 'C : / ProgramData / MySQL / MySQL Server 5.7 / Uploads / readerinfo1 .txt '
Fields terminated by', '
Lines terminated by' \ R & lt \ n-';

- Use mysqldump command to export bookcategory under the table book library
mysqldump -T "C: / ProgramData / MySQL / MySQL Server 5.7 / Uploads" -uroot -p book bookcategory

- use the mysql command to export readerinfo under the table book library to readerinfo2.txt
mysql-uroot---execute = -p "the SELECT * from readerinfo;" book> "C: / ProgramData / MySQL / MySQL Server 5.7 / the Uploads / readerinfo2. TXT"

- using the load data infile command to import the data table readerinfo
load data infile "C: / ProgramData / MySQL / MySQL Server 5.7 / Uploads / readerinfo.txt" into table book.readerinfo;


- Use the mysqlimport command to import data readerinfo table
mysqlimport -uroot -p book "C: / ProgramData / MySQL / MySQL Server 5.7 / Uploads / readerinfo.txt"

 

Guess you like

Origin www.cnblogs.com/xiaomifeng1010/p/11484782.html