建立用戶並賦予權限html
grant all on *.* to 'user1' identified by '123456a'; #建立user1密碼爲123456a,權限爲all grant all on *.* to 'user1'@'localhost' identified by '123456a'; #此處與上面命令的區別是設置了登陸來源ip grant all on *.* to 'user1'@'%' identified by '123456a'; #此設置了登陸來源ip爲全部
刷新以後才能生效mysql
flush privileges;
查看權限linux
show grants;
運行效果以下所示sql
mysql> show grants; +-----------------------------------------------------------------------------------------------------------------------+ | Grants for user1@localhost | +-----------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*B012E8731FF1DF44F3D8B26837708985278C3CED' | +-----------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
查看指定用戶的權限數據庫
show grants for user1@'127.0.0.1';
# 查詢 select count(*) from mysql.user; select * from mysql.db; select db from mysql.db; select db,user from mysql.db; select * from mysql.db where host like '192.168.%'; #模糊查詢 # 插入 insert into db1.t1 values (1, 'abc'); # 更新 update db1.t1 set name='aaa' where id=1; # 清空表 truncate table db1.t1; # 刪除 drop table db1.t1; drop database db1;
1.備份庫文件ide
mysqldump -uroot -pmysql123 mysql > /tmp/mysql_bak.sql
2.建立數據庫mysql2而且將步驟1的備份文件恢復到mysql2測試
建立測試庫mysql2.net
mysql -uroot -pmysql123 -e "create database mysql2";
恢復到mysql2code
mysql -uroot -pmysql123 mysql2 < /tmp/mysql_bak.sql
查看是否恢復成功htm
1.進入指定的數據庫
mysql -uroot -pmysql123 mysql2
2.查詢當前所在數據庫
mysql> select database(); +------------+ | database() | +------------+ | mysql2 | +------------+ 1 row in set (0.00 sec)
3.查看錶
show tables;
3.備份表
mysqldump -uroot -pmysql123 mysql user > /tmp/user_bak.sql
4.恢復表
mysqldump -uroot -pmysql123 mysql2 user < /tmp/user_bak.sql
5.備份全部庫
mysqldump -uroot -pmysql123 -A > /tmp/user_all.sql
6.只備份指定數據庫的全部表結構(至關於複製建立表語句)
mysqldump -uroot -pmysql123 -d mysql2 > /tmp/mysql2_table.sql
SQL語句教程 http://www.runoob.com/sql/sql-tutorial.html
什麼是事務?事務的特性有哪些? http://blog.csdn.net/yenange/article/details/7556094
根據binlog恢復指定時間段的數據 http://www.javashuo.com/article/p-mfppegny-r.html
相關擴展 https://blog.csdn.net/linuxheik/article/details/71480882
mysql字符集調整 http://xjsunjie.blog.51cto.com/999372/1355013
使用xtrabackup備份innodb引擎的數據庫 innobackupex 備份 Xtrabackup 增量備份 http://zhangguangzhi.top/2017/08/23/innobackex%E5%B7%A5%E5%85%B7%E5%A4%87%E4%BB%BDmysql%E6%95%B0%E6%8D%AE/#%E4%B8%89%E3%80%81%E5%BC%80%E5%A7%8B%E6%81%A2%E5%A4%8Dmysql