美文网首页
sql基本语句

sql基本语句

作者: 姜饼人_9e7b | 来源:发表于2017-08-09 16:04 被阅读0次

1、mysql_secure_installation 设置数据库密码

2、mysql -u root -p password -h 127.0.0.1;
以root账号,本地ip 127.0.0.1登录数据库

3、show databases;
查看数据库

4、use luodb;
进入数据库luodb

5、desc table1;
列出table1

6、select * from table1;
列出table1所有信息。

7、help 查看帮助


1、登录数据库:

[root@Centos7 ~]#mysql -uroot -p666666 -h 127.0.0.1
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 99
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2、查看数据库

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| blogdb             |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)
#有5个数据库

3、进入"mysql"这个数据库

MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

4、列出当前数据库的表格

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| time_zone_transition_type |
| user                      |
...部分省略
+---------------------------+
24 rows in set (0.00 sec)
#列出当前数据库的表格,可以看到有24个表格

5、查看user这个表格的结构

MariaDB [mysql]> desc user
    -> ;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field                  | Type                              | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host                   | char(60)                          | NO   | PRI |         |       |
| User                   | char(16)                          | NO   | PRI |         |       |
| Password               | char(41)                          | NO   |     |         |       |
| Select_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N       |       |

...部分省略

42 rows in set (0.00 sec)

6、列出表格”user“的host、user、password三个字段的信息。

MariaDB [mysql]> select host,name,password from user;
ERROR 1054 (42S22): Unknown column 'name' in 'field list'
MariaDB [mysql]> select host,user,password from user;
+-----------------+--------+-------------------------------------------+
| host            | user   | password                                  |
+-----------------+--------+-------------------------------------------+
| localhost       | root   | *B2B366CA5C4697F31D4C55D61F0B17E70E5664EC |
| centos7.luo.com | root   | *B2B366CA5C4697F31D4C55D61F0B17E70E5664EC |
| 127.0.0.1       | root   | *B2B366CA5C4697F31D4C55D61F0B17E70E5664EC |
| ::1             | root   | *B2B366CA5C4697F31D4C55D61F0B17E70E5664EC |
| 127.0.0.1       | wpuser | *B2B366CA5C4697F31D4C55D61F0B17E70E5664EC |
+-----------------+--------+-------------------------------------------+
5 rows in set (0.00 sec)

7、help

MariaDB [mysql]> help

相关文章

  • SQL语句基本使用

    SQL语句基本使用——增删改查 SQL语句基本使用——WHERE子句 SQL语句基本使用——AND和OR的使用 S...

  • 基本SQL语句

    1.下图book为表名称,number,name等为字段名。 注:筛选book表中的数据 #sql基本 增删改查语...

  • SQL基本语句

    一、SQL SELECT 语句 SELECT 语句用于从数据库中选取数据。结果被存储在一个结果表中,称为"结果集"...

  • 基本SQL语句

    orm数据库用的多了,重新学习sql语句。在win环境下直接下载(SQLite Expert Profession...

  • sql基本语句

    1、mysql_secure_installation 设置数据库密码 2、mysql -u root -p pa...

  • 基本sql语句

    增: 1.insert into table1(field1,field2) values(value1,valu...

  • SQL基本语句

    查询语句:select select 字段1,字段2,字段3....字段nfrom 表名where 查询条件ord...

  • 基本SQL语句

    SELECT查询语句: SELECT 列名称 FROM 表名称 WHERE 列 运算符 值; SELECT 列名称...

  • SQL基本语句

    1、创建软连接 连接数据库 效果如图: 2、创建数据库(即模式) 效果如图: 2.1查看数据库: 终端效果如图: ...

  • mysql数据库查询语句

    1.简单的查询基本表的SQL语句 (1)查询语句 (2)查询语句 Student表的删除SQL语句: 选课表的操作...

网友评论

      本文标题:sql基本语句

      本文链接:https://www.haomeiwen.com/subject/khvalxtx.html