饿虎岗资源网 Design By www.oxmxm.com
在日常的网站维护和管理中,会用到非常多的SQL语句,
熟练使用对网站管理有很多好处,尤其是站群管理的时候。
下面列一些常用的命令做备记。
1、显示数据库
show databases
显示表
show tables;
2、创建用户
创建root用户密码为123
use mysql; grant all on *.* to root@'%' identified by '123' with grant option; commit;
3、修改密码
grant all on *.* to xing@'localhost' identified by '123456' with grant option; update user set password = password('newpwd') where user = 'xing' and host='localhost'; flush privileges;
4、创建数据库testdb:
create database testdb;
5、预防性创建数据库:
create database if not testdb;
6、创建表:
use testdb; create table table1( username varchar(12), password varchar(20));
7、预防性创建表aaa:
create table if not exists aaa(ss varchar(20));
8、查看表结构:
describe table1;
9、插入数据到表table1:
insert into table1(username,password) values ('leizhimin','lavasoft'), ('hellokitty','hahhahah'); commit;
10、查询表table1:
select * from table1;
11、更改数据:
update table1 set password='hehe' where username='hellokitty'; commit;
12、删除数据:
delete from table1 where username='hellokitty'; commit;
13、给表添加一列:
alter table table1 add column( sex varchar(2) comment '性别', age date not null comment '年龄' ); commit;
14、修改表结构
从查询创建一个表table1:
create table tmp as select * from table1;
15、删除表table1:
drop table if exists table1; drop table if exists tmp;
16、备份数据库testdb
mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk >C:\testdb.sql
17、删除数据库testdb
drop database testdb;
18、恢复testdb数据库
首先先建立testdb数据库,然后用下面命令进行本地恢复
mysql -u root -pleizhimin testdb <C:\testdb.sql
这18个MYSQL命令都是管理员在日常维护中经常会用到的,熟练使用这些命令会使你的工作非常轻松
饿虎岗资源网 Design By www.oxmxm.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
饿虎岗资源网 Design By www.oxmxm.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 《绝对主打 流行原创金曲 2CD》[WAV分轨][1.1GB]
- 《赛博朋克2077》更新上线:支持AMD FSR3
- 《塞尔达传说:智慧的再现》提前半个月偷跑,引发玩家担忧
- 战锤40K星际战士2全职业介绍|全职业技能效果一览
- 陈百强《2006世纪10星·永恒篇[环球]》[WAV整轨]
- 【新世纪钢琴】VA-GoldenOctober(Piano)(金秋十月钢琴篇)【FLAC】
- 青稞荞麦《破茧》新生代组合[WAV+CUE]
- 因系统升级后出现BUG 《FF16》PS5完全版宣布延期
- 《黑神话:悟空》周伯通!大佬用左右手分别挑战两只虎先锋
- 《黑神话:悟空》攻击动作致敬《大话西游》:这也太帅了!
- 《星舰铳犬太阳系物语》游戏背景介绍
- 《战锤40K星际战士2》终极版有后续DLC说明
- 《第9层》游戏特色玩法介绍
- 刀郎.2006-刀郎【九雨天下】【WAV+CUE】
- 59.9高校生.1994-素兰万岁【上华】【WAV+CUE】