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]
新浪微博@皮子喜欢打篮球
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]
新浪微博@皮子喜欢打篮球
相关文章推荐
- Linux Deepin 2014 cpu温度与频率设定
- linux识别ntfs文件系统
- Linux下 FTP 常见错误 500 530等错误解决方法
- 去掉redhat linux提示注册
- CentOS7启动报sd 0:0:0:0: [sda] Assuming drive cache: write through
- Linux下搭建nodejs + npm + express环境
- linux之ps命令简单使用
- linux(ubuntu)下分区和格式化sd卡
- linux 硬盘读写性能测试
- centos下pip安装mysql_python
- 如何在MacBook Pro Retina上安装Linux
- linux ip地址设置(静态)
- Linux图形界面的安装和卸载
- CentOS6.6配置iptables
- 在centos7 ubuntu15.04 上通过bosh-lite 搭建单机环境cloudfoundry
- CentOS 5 centos 6下安装Axel插件加速yum下载
- centos 配置Openssl并创建证书
- Linux常用命令大全
- Linux rpm 命令参数使用详解[介绍和应用]
- Thinking In Linux C/C++字节对齐详解