在日常的网站维护和MYSQL数据库管理中,我们经常会用到非常多的MYSQL命令,为了方便大家整理,小编列举了18个管理MYSQL数据库时最常使用的命令。在日常的网站维护和管理中,会用到非常多的SQL语句,
熟练使用对网站管理有很多好处,尤其是站群管理的时候。
下面列一些常用的命令做备记。
show databases
显示表
show tables;
创建root用户密码为123
use mysql;
grant all on *.* to root@'%' identified by '123' with grant option;
commit;
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;
create database testdb;
create database ifnot testdb;
use testdb;
create table table1(
username varchar(12),
password varchar(20));
create table ifnot exists aaa(ss varchar(20));
describe table1;
insert into table1(username,password) values
('leizhimin','lavasoft'),
('hellokitty','hahhahah');
commit;
select * from table1;
update table1 set password='hehe' where username='hellokitty';
commit;
delete from table1 where username='hellokitty';
commit;
alter table table1 add column(
sex varchar(2) comment '性别',
age date not null comment '年龄'
);
commit;
从查询创建一个表table1:
create table tmp as
select * from table1;
drop table ifexists table1;
drop table ifexists tmp;
mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk >C:\testdb.sql
drop database testdb;
首先先建立testdb数据库,然后用下面命令进行本地恢复
mysql -u root -pleizhimin testdb <C:\testdb.sql
这18个MYSQL命令都是管理员在日常维护中经常会用到的,熟练使用这些命令会使你的工作非常轻松
按字母顺序浏览:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
→我们致力于为广大网民解决所遇到的各种电脑技术问题 如果您认为本词条还有待完善,请 编辑词条
上一篇MYSQL数据损坏修复方法
下一篇Mysql不停机开启主从复制