mysql ubuntu 17.04_1、mysql 5.7 ubuntu17.04
系統(tǒng):ubuntu17.04
數(shù)據(jù)庫(kù)主要分文檔型和服務(wù)型兩類:
文檔型:如sqlite3 (17.04自帶/usr/bin/sqlite3)就是一個(gè)文件,應(yīng)用在移動(dòng)端如手機(jī),pad,家電等
服務(wù)型:如mysql有服務(wù)端(存儲(chǔ)數(shù)據(jù))和客戶端
mysql數(shù)據(jù)庫(kù)是關(guān)系型數(shù)據(jù)庫(kù),采用E-R模型即實(shí)體-聯(lián)系(或關(guān)系)模型
安裝:
sudo apt install mysql-server,需要設(shè)置密碼: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; #初始有四個(gè)數(shù)據(jù)庫(kù)+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.16sec)
創(chuàng)建用戶并授權(quán):
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表的結(jié)構(gòu),如下:
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| 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 | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
注:字段創(chuàng)建要有數(shù)據(jù)類型,長(zhǎng)度;Null是否為空,NO表示不能為空;PRI表示主鍵,一般是一個(gè),本表前兩個(gè)是聯(lián)合主鍵
select ?字段 ?from ?表
exit; #從mysql數(shù)據(jù)庫(kù)退出
ps -ef |grep mysql #在命令行從所有進(jìn)程篩選mysql
總結(jié)
以上是生活随笔為你收集整理的mysql ubuntu 17.04_1、mysql 5.7 ubuntu17.04的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在农村开个什么小型工厂好 教你选择适合
- 下一篇: 五险一个月要交多少钱 可以根据这个比例