【Linux】-- Mysql(1):简介和安装使用

4 篇文章 0 订阅

系统环境

Ubuntu 14.04 64位版本


简述

SQL

结构化查询语句(Strructured Query Language), 用于对数据库进行操作的语言,更详细的说,SQL 是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统,同时也是数据库脚本文件的扩展名


MySQL

MySQL 是一个 DBMS(数据库管理系统),MySQL 是最流行的关系型数据库管理系统(关系数据库,是建立在关系数据库模型基础上的数据库,借助于集合代数等概念和方法来处理数据库中的数据)。


MySQL 的安装

检查是否安装
pinsily@zhu ~$ sudo service mysql start
mysql: unrecognized service

如果出现以上显示则没有安装

安装
# 更新软件库
pinsily@zhu ~$ sudo apt-get update

# 安装 Mysql 服务端
pinsily@zhu ~$ sudo apt-get install mysql-server

# 安装 Mysql 客户端,期间需要设置密码,这是登录 mysql 的密码,务必记住
pinsily@zhu ~$ sudo apt-get install mysql-client


验证安装是否成功
# 以下提示则安装成功
pinsily@zhu ~$ sudo netstat -tag | grep mysql
tcp        0      0 localhost:mysql         *:*                     LISTEN     

初步使用

启动 Mysql
# 启动 Mysql 服务
pinsily@zhu ~$ sudo service mysql start

……

# 使用 root 用户登录,接下来输入密码
pinsily@zhu ~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.55-0ubuntu0.14.04.1 (Ubuntu)

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

Oracle is 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> 

命令中的 -u 表示 user ,-p 表示 password,空密码的 mysql 用户不用 -p 选项


查看数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)


连接数据库 use database_name;
mysql> 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


查看数据库表
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| GLOBAL_STATUS                         |
| GLOBAL_VARIABLES                      |
| KEY_COLUMN_USAGE                      |
| PARAMETERS                            |


退出

使用 exitquit 命令退出 mysql

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值