52次课(mysql用户管理、常用sql语句、 mysql数据库备份恢复)
MySQL創建用戶以及授權
默認用戶是root用戶,不可能所有人員都用root用戶,創建用戶防止誤刪除,因為mysql里邊有多個庫每個庫里有很多表,所以需要給單獨的用戶做一些授權我只需要它對某一個數據庫有權限,或者說對某個數據庫的某個表設置權限,
創建用戶
mysql> grant all on *.* to 'user1'@'127.0.0.1' identified by '123456'; ##創建user1用戶指定ip訪問密碼為123, @后面可以加個統配%就是所有的IPquit退出去做測試
針對具體的權限授權
mysql> grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.63.1' identified by '123';查看user2的授權
mysql> show grants for user2@'192.168.63.1';給user2在添加個授權ip
show grants;查詢授權
常用sql語句
select=查看 insert=插入 update=更改
查詢庫表的行數
mysql>select count(*) from mysql.user; ##查看mysql庫的user表行數查看所有的內容
mysql> select * from mysql.db\G;單個字段和兩個字段查詢
mysql> select db from mysql.db; mysql> select db,user from mysql.db;模糊查詢
mysql> select * from mysql.db where host like '192.168.%'\G;表里邊插入數據
mysql> insert into db1.t1 values (1, 'abc');刪除表內容
mysql> delete from db1.t1 where id=1清空表內容
mysql> truncate table db1.t1;刪除庫和表
drop table db1.t1;
drop database db1;
mysql數據庫備份恢復
mysqldump=數據備份的命令
備份庫
恢復庫數據庫恢復可以恢復到另外一個庫里
[root@100xuni1 ~]# mysql -uroot -phanshuo1 mysql2 < /tmp/mysqlbak.sql備份表
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 mysql user > /tmp/userbak.sql恢復備份表
[root@100xuni1 ~]# mysql -uroot -phanshuo1 mysql2 < /tmp/userbak.sql備份所有的庫
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 -A > /tmp/123.sql只備份表結構
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 -d mysql2 > /tmp/mysql2.sql擴展
SQL語句教程 http://www.runoob.com/sql/sql-tutorial.html
什么是事務?事務的特性有哪些? http://blog.csdn.net/yenange/article/details/7556094
根據binlog恢復指定時間段的數據 https://blog.csdn.net/lilongsy/article/details/74726002
相關擴展 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
**相關視頻
鏈接:http://pan.baidu.com/s/1miFpS9M
密碼:86dx
鏈接:http://pan.baidu.com/s/1o7GXBBW
密碼:ue2f
**
轉載于:https://blog.51cto.com/8043410/2163373
總結
以上是生活随笔為你收集整理的52次课(mysql用户管理、常用sql语句、 mysql数据库备份恢复)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Please remove usages
- 下一篇: SQLServer约束介绍