linux系统中mysql控制台的一些常用命令

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/foreverlikui/article/details/78878392

            在linux中,我们可以通过在linux控制台根目录输入:mysql -u 用户名 -p之后,输入mysql密码,进入mysql控制台。 

             

            在此控制台中,可以输入所有mysql语句,比如创建删除数据库、数据表,插入数据、查询数据等等。

            常用的一些命令我列一下仅供参考:

            其它的mysql数据库相关的操作如下 

            (1) 创建数据库TestDB mysql> create database TestDB; 

            (2) 制定TestDB数据库为当前默认数据库 mysql> use TestDB; 

            (3) 在TestDB数据库中创建表customers mysql> create table customers(userid int not null, username varchar(20) not null); 

            (4) 显示数据库列表 mysql> show databases; 

            (5)显示数据库中的表 mysql> show tables; 

            (6)删除表customers mysql> drop table customers; 

            (7)显示customers表的结构 mysql> desc customers; 

            (8) 向customers表中插入一条记录 mysql> insert into customers(userid, username) values(1, 'hujiahui'); 

            (9) 让操作及时生效; mysql> commit; 

            (10) 查询customers中的记录 mysql> select * from customers; 

            (11) 更新表中的数据 mysql> update customers set username='DennisHu' where userid=1; 

            (12) 删除表中的记录 mysql> delete from customers; 

            2(13)授予likui用户访问数据库的权限 # grant select, insert, update, delete on *.* to likui@localhost indentified by "123456";

猜你喜欢

转载自blog.csdn.net/foreverlikui/article/details/78878392