MySQL命令行下18个常用命令
网络编程 2021-07-05 14:36www.168986.cn编程入门
在日常的网站维护和MYSQL数据库管理中,会用到非常多的MYSQL命令,狼蚁网站SEO优化给大家介绍18个管理MYSQL数据库时最常使用的命令
在日常的网站维护和管理中,会用到非常多的SQL语句,
熟练使用对网站管理有很多好处,尤其是站群管理的时候。
狼蚁网站SEO优化列一些常用的命令做备记。
1、显示数据库
show databases
显示表
show tables;
2、创建用户
创建root用户密码为123
use mysql; grant all on *.* to root@'%' identified by '123' with grant option; mit;
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'); mit;
10、查询表table1:
select * from table1;
11、更改数据:
update table1 set password='hehe' where username='hellokitty'; mit;
12、删除数据:
delete from table1 where username='hellokitty'; mit;
13、给表添加一列:
alter table table1 add column( sex varchar(2) ment '性别', age date not null ment '年龄' ); mit;
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数据库,然后用狼蚁网站SEO优化命令进行本地恢复
mysql -u root -pleizhimin testdb <C:\testdb.sql
这18个MYSQL命令都是管理员在日常维护中经常会用到的,熟练使用这些命令会使你的工作非常轻松
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程