树莓派学习——MySQL搭建和使用

树莓派3B平台下搭建Mysql,并建库进行增删改读。

 

 

命令行:

1:更新源            sudo apt-get update

2:安装mysql server      sudo apt-get install mysql-server      此过程中会提示输入密码,后面打开sql时用到

3:启动mysql server      mysql -u root -p               此过程中会提示输入密码,键入之前安装sql时的密码

 

 

 

MySQL控制台

4:查看工作路径       show variables like "%datadir%";            如果要修改该路径,可参照 http://www.linuxidc.com/Linux/2017-02/140231.htm

 

5:查看现有的数据库                show databases;

6:创建数据库         create database raspidb;i

 

7:使用raspsb库        use raspdb;

8:创建行列          create table cpuinfo(recordtime Date,temp Decimal(4,1));       创建一个时间和温度(4位数包含1位i小数)

9:查看表           describe cpuinfo;

 

10:插入信息                            

一条

  insert into cpuinfo values('2017-01-01',5);

多条

  insert into cpuinfo(recordtime,temp) values('2017-02-01',10),('2017-02-02',20);

 

11:查看表         select *from cpuinfo;

12:复制表         create table cpu as select * from cpuinfo;

 

 

13:修改字段          update cpu set recodtime='2017-03-01',temp=10 where recordtime='2017-02-02';

 

14:删除表         drop table cpu;

15:删除字段          delete from cpuinfo where recordtime='2017-01-01';

 

 

posted @ 2017-09-26 15:57  cy_07  阅读(828)  评论(0编辑  收藏  举报