您的位置:首页 > 运维架构 > Linux

linux下mysql常用的命令

2015-07-31 14:21 645 查看
摘要: 运维人员常用命令,例如增删改查。。

linux下搭建完mysql后,一些常用的数据库命令:

创建库:create database mydatabase;
显示所有数据库列表:show databases;
删除数据库:drop dabatase mydatabase;
制定mydatabase为当前默认数据库:use mydatabase;
创建表:create table custmoers(userid int not null,username varchar(20)not null);
删除表:drop table cutomers;
显示表:show tables;
显示表结构:desc customers;
向customers表中插入一条记录:insert into customers(userid,username) values(1,'hujiahui');
让操作即时生效:commit;
查询customers中的记录:select * from customers;
更新表中的数据:update customers set username='licongying' where userid=1;
删除表中的记录:delete from customers;
授予hjh用户访问数据库的权限:grant select,insert,update,delete on *.* to hjh@localhost identified by"123456",其中hjh是用户名
123456是密码
登录mysql:mysql -uhjh -p123456


更改mysql里user的密码:【以root为例】

[b]mysql -uroot -p[/b]

Enter password: 【输入原来的密码】
mysql>[b]use mysql;

mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;

[/b]

新浪微博@皮子喜欢打篮球
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: