• 3mysql数据库操作


    1创建用户

    
    
    create user 'alex'@'192.168.1.1' identified by '159357'; #指定Ip
    
    
    create user 'alex'@'192.168.1.%' identified by '159357'; #Ip前面部分只要匹配即可

    create
    user 'alex'@'%' identified by '159357'; #不限Ip

    2指定权限

    grant select,insert,update on db1.t1 to 'alex'@'%'; #指定 select,insert,update权限
    grant all privileges  on db1.t1 to 'alex'@'%'; #指定所有权限

    3操作数据库

    create database db1;
    create database db2 default charset utf8; #考虑中文,数据库整个是utf8格式 show databases;
    drop database db1;

    4操作表

    create table t1 (id int(10),
                           name char(20),
                           phone int(12));
    create table t1 (id int(10),
                           name char(20),
                           phone int(12)
              ) default charset=utf8; #
    考虑中文,表整个是utf8格式
    create table t1 (id int(10),
                           name char(20),
                           phone int(12)
              ) engine=innodb default charset=utf8;
    innodb 支持事务
    myisam 不支持事务

    create table t1 (id int(10),
                  列名 类型 null,
                  列名 类型 not null,
                  列名 类型 not null default 1,
                  列名 类型 auto_increment primary key, #auto_increment 表示:自增 primary key :表示 约束(不能重复且不能为空);加速查找 name char(20), phone int(12)
              ) engine=innodb default charset=utf8;
    show tables;
    select * from t1;
    insert into t1(id,name,phone) values(01,'xiaoming',111222333);
    
    insert into 表的名字(列名a,列名b,列名c) values(值1,值2,值3);
    delete from t1;  #清空表
    trancate table t1; #清空表
    drop table t1;删除表
  • 相关阅读:
    Android NDK 开发中 adb logcat 命令的使用
    android 工程里缺少 R.java 文件原因和解决方法
    用Linux命令行实现删除和复制指定类型的文件
    重载操作符与转换
    复制控制
    管理类的指针成员
    复制构造函数
    static类成员(变量和函数)
    lock failed, MQ already started 问题处理
    Mac无法启动RocketMQ,日志显示,runserver.sh: line 91: /Library/Internet: No such file or directory
  • 原文地址:https://www.cnblogs.com/gao-chao/p/13252598.html
Copyright © 2020-2023  润新知