当前位置:Gxlcms > 数据库问题 > mysql 常用命令

mysql 常用命令

时间:2021-07-01 10:21:17 帮助过:3人阅读

MySQL日常操作命令:

show databases; 查看数据库

create database test_db; 创建名为test_db数据库

use test_db; 进入test_db数据库。

show tables; 查看数据库里有多少张表。

 

 create table test01 (id varchar(20),name varchar(20));  创建数据表 id、name、数据长度(用字符来定义长度单位。)

insert into test01 values (“001”,“ming”);向表中插入数据。

select *from test01; 查看test01表数据内容

 

Grant  all  on test_db.*  to  test@localhost identified by ‘123456‘;

grant  all  on  test_db.*      to  test@localhost    identified by ‘123456‘;

grant  select,insert,update,delete on *.* to test@”%”  identified by  ‘123456’;

 

给mysql数据库授权:

flush  privileges;刷新权限

mysqldump –uroot –p123456  test_db >/tmp/test.db.sql ;MySQL备份或导出

mysql –uroot –p123456 test_db  < /tmp/test.db.sql        ;  MySQL导入

 

修改MySQL root密码

mysqladmin –uroot –p123456 password   newpassword    ;

 

drop database test_db ; 删除数据库

drop table test01 ;  删除表

delete from test01 ; 清空表内容

  

 

mysql 常用命令

标签:修改   show   create   root   har   new   admin   update   table   

人气教程排行