52次课(mysql用户管理、常用sql语句、 mysql数据库备份恢复)
MySQL創(chuàng)建用戶以及授權(quán)
默認(rèn)用戶是root用戶,不可能所有人員都用root用戶,創(chuàng)建用戶防止誤刪除,因?yàn)閙ysql里邊有多個(gè)庫(kù)每個(gè)庫(kù)里有很多表,所以需要給單獨(dú)的用戶做一些授權(quán)我只需要它對(duì)某一個(gè)數(shù)據(jù)庫(kù)有權(quán)限,或者說(shuō)對(duì)某個(gè)數(shù)據(jù)庫(kù)的某個(gè)表設(shè)置權(quán)限,
創(chuàng)建用戶
mysql> grant all on *.* to 'user1'@'127.0.0.1' identified by '123456'; ##創(chuàng)建user1用戶指定ip訪問(wèn)密碼為123, @后面可以加個(gè)統(tǒng)配%就是所有的IPquit退出去做測(cè)試
針對(duì)具體的權(quán)限授權(quán)
mysql> grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.63.1' identified by '123';查看user2的授權(quán)
mysql> show grants for user2@'192.168.63.1';給user2在添加個(gè)授權(quán)ip
show grants;查詢授權(quán)
常用sql語(yǔ)句
select=查看 insert=插入 update=更改
查詢庫(kù)表的行數(shù)
mysql>select count(*) from mysql.user; ##查看mysql庫(kù)的user表行數(shù)查看所有的內(nèi)容
mysql> select * from mysql.db\G;單個(gè)字段和兩個(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;表里邊插入數(shù)據(jù)
mysql> insert into db1.t1 values (1, 'abc');刪除表內(nèi)容
mysql> delete from db1.t1 where id=1清空表內(nèi)容
mysql> truncate table db1.t1;刪除庫(kù)和表
drop table db1.t1;
drop database db1;
mysql數(shù)據(jù)庫(kù)備份恢復(fù)
mysqldump=數(shù)據(jù)備份的命令
備份庫(kù)
恢復(fù)庫(kù)數(shù)據(jù)庫(kù)恢復(fù)可以恢復(fù)到另外一個(gè)庫(kù)里
[root@100xuni1 ~]# mysql -uroot -phanshuo1 mysql2 < /tmp/mysqlbak.sql備份表
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 mysql user > /tmp/userbak.sql恢復(fù)備份表
[root@100xuni1 ~]# mysql -uroot -phanshuo1 mysql2 < /tmp/userbak.sql備份所有的庫(kù)
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 -A > /tmp/123.sql只備份表結(jié)構(gòu)
[root@100xuni1 ~]# mysqldump -uroot -phanshuo1 -d mysql2 > /tmp/mysql2.sql擴(kuò)展
SQL語(yǔ)句教程 http://www.runoob.com/sql/sql-tutorial.html
什么是事務(wù)?事務(wù)的特性有哪些? http://blog.csdn.net/yenange/article/details/7556094
根據(jù)binlog恢復(fù)指定時(shí)間段的數(shù)據(jù) https://blog.csdn.net/lilongsy/article/details/74726002
相關(guān)擴(kuò)展 https://blog.csdn.net/linuxheik/article/details/71480882
mysql字符集調(diào)整 http://xjsunjie.blog.51cto.com/999372/1355013
使用xtrabackup備份innodb引擎的數(shù)據(jù)庫(kù) 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
**相關(guān)視頻
鏈接:http://pan.baidu.com/s/1miFpS9M
密碼:86dx
鏈接:http://pan.baidu.com/s/1o7GXBBW
密碼:ue2f
**
轉(zhuǎn)載于:https://blog.51cto.com/8043410/2163373
總結(jié)
以上是生活随笔為你收集整理的52次课(mysql用户管理、常用sql语句、 mysql数据库备份恢复)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Please remove usages
- 下一篇: 某云,下载.ncm格式自动转换为flac