小标
2019-02-20
来源 :
阅读 908
评论 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;
创建数据库并使用
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
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号