mysql ubuntu 17.04_1、mysql 5.7 ubuntu17.04

系统:ubuntu17.04

数据库主要分文档型和服务型两类:

文档型:如sqlite3 (17.04自带/usr/bin/sqlite3)就是一个文件,应用在移动端如手机,pad,家电等

服务型:如mysql有服务端(存储数据)和客户端

mysql数据库是关系型数据库,采用E-R模型即实体-联系(或关系)模型

安装:

sudo apt install mysql-server,需要设置密码:xxx

sudo apt install mysql-client

sudo apt install libmysqlclient-dev

lyb@lyb:~$ sudo netstat -tap |grep mysql

tcp0 0 localhost:mysql *:* LISTEN 5167/mysqld

成功安装

登录:

l@l:~$ mysql -uroot -pxxx

mysql: [Warning] Using a password on the command lineinterfacecan be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection idis 5Server version:5.7.20-0ubuntu0.16.04.1(Ubuntu)

Copyright (c)2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracleis a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

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

mysql>show databases;  #初始有四个数据库+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.16sec)

创建用户并授权:

mysql> create user 'l'@'%' identified by '123';

Query OK,0 rows affected (0.09sec)

mysql> select user,host fromuser;+---------------+-----------+

| user | host |

+---------------+-----------+

| l | % |

| mysql.session | localhost |

| mysql.sys | localhost |

| root | localhost |

+---------------+-----------+

4 rows in set (0.00sec)

mysql> grant select on study.* to 'l'@'%';

desc  user;  #显示其中user表的结构,如下:

+------------------------+-----------------------------------+------+-----+-----------------------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------------------+-----------------------------------+------+-----+-----------------------+-------+

| Host | char(60) | NO | PRI | | |

| User | char(32) | NO | PRI | | |

| Select_priv | enum('N','Y') | NO | | N | |

| Insert_priv | enum('N','Y') | NO | | N | |

| Update_priv | enum('N','Y') | NO | | N | |

| Delete_priv | enum('N','Y') | NO | | N | |

| Create_priv | enum('N','Y') | NO | | N | |

| Drop_priv | enum('N','Y') | NO | | N | |

| Reload_priv | enum('N','Y') | NO | | N | |

| Shutdown_priv | enum('N','Y') | NO | | N | |

| max_user_connections | int(11) unsigned | NO | | 0 | |

| plugin | char(64) | NO | | mysql_native_password | |

| authentication_string | text | YES | | NULL | |

| password_expired | enum('N','Y') | NO | | N | |

| password_last_changed | timestamp | YES | | NULL | |

| password_lifetime | smallint(5) unsigned | YES | | NULL | |

| account_locked | enum('N','Y') | NO | | N | |

+------------------------+-----------------------------------+------+-----+-----------------------+-------+

注:字段创建要有数据类型,长度;Null是否为空,NO表示不能为空;PRI表示主键,一般是一个,本表前两个是联合主键

select  字段  from  表

exit;  #从mysql数据库退出

ps -ef |grep mysql  #在命令行从所有进程筛选mysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值