【云计算】MySQL入门到精通
小标 2019-01-23 来源 : 阅读 1032 评论 0

摘要:本文主要向大家介绍了【云计算】MySQL入门到精通,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。

本文主要向大家介绍了【云计算】MySQL入门到精通,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。


安装


su root
yum install mysql-server
yum install mysql
yum install mysql-devel


启动sql服务器


/etc/init.d/mysqld restart
如果是在非root环境用下面的命令即可
sudo service mysqld start;


用户登陆


mysql -u用户名 -p密码;
mysql -uroot -proot;


<h2 id="创建数据库并使用">创建数据库并使用

mysql> create database bigdb;
Query OK, 1 row affected (0.01 sec)

mysql> use bigdb;
Database changed

mysql> show tables;
Empty set (0.00 sec)

查看存储引擎


mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)

创建表


mysql> create table brand(
    -> bid varchar(9) not null,
    -> category varchar(10) not null,
    -> shop varchar(8) not null) 
    -> engine=innodb 
    -> default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+-----------------+
| Tables_in_bigdb |
+-----------------+
| brand           |
+-----------------+
1 row in set (0.00 sec)

mysql> show create table brand;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                             |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| brand | CREATE TABLE `brand` (
  `bid` varchar(9) NOT NULL,
  `category` varchar(10) NOT NULL,
  `shop` varchar(8) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> 

导入表


## 错误示例1 ##
mysql> load data infile '/home/bigdata/datasource/brand.list'
    -> into table brand 
    -> fields terminated by ','
    -> lines terminated by '¥n';
ERROR 13 (HY000): Can't get stat of '/home/bigdata/datasource/brand.list' (Errcode: 13)

## 错误示例2 ##
mysql> load local  data infile '/home/bigdata/datasource/brand.list'
    -> into table brand 
    -> fields terminated by ','
    -> lines terminated by '¥n';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'local  data infile '/home/bigdata/datasource/brand.list'
into table brand 
field' at line 1

## 正确示例 ##
mysql> load data local infile '/home/bigdata/datasource/brand.list'
    -> into table brand 
    -> fields terminated by ','
    -> lines terminated by '\n';
Query OK, 1000 rows affected, 87 warnings (0.00 sec)
Records: 1000  Deleted: 0  Skipped: 0  Warnings: 87
mysql> 

mysql> select * from brand limit 5;
+----------+-----------+----------+
| bid      | category  | shop     |
+----------+-----------+----------+
| 00000000 | telephone | OPPO     |
| 00000001 | computer  | ASUS     |
| 00000002 | sports    | MIZUNO   |
| 00000003 | sports    | LINING   |
+----------+-----------+----------+
5 rows in set (0.00 sec)

mysql> 


          

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标大数据云计算大数据安全频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved