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

            linux系统中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 [email protected] indentified by "123456";

相关文章:

  • 2022-12-23
  • 2021-06-17
  • 2021-09-16
  • 2022-02-23
  • 2021-06-19
  • 2021-07-03
猜你喜欢
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-12-02
  • 2022-02-19
  • 2021-07-19
相关资源
相似解决方案