zoukankan      html  css  js  c++  java
  • mysql 常用基础

    登录命令 -h远程IP地址 -u用户名 -p密码 -P端口

    mysql -h127.0.0.1 -uroot -p21313 -P3306

    新建用户

    insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));

    刷新权限

    flush privileges;

    创建数据库

    create database 数据库名;

    显示数据库

    show databases;

    切换数据库

    use 数据库名;

    数据库授权

    grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';

    grant select,update on phplampDB.* to phplamp@localhost identified by '1234';

    删除用户

    DELETE FROM user WHERE User="phplamp" and Host="localhost";

    删除数据库

    drop database 数据库名;

    修改用户密码

    update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";

    创建定时任务

    定时将A表数据统计 转存另一张表中

    delimiter |
    CREATE EVENT e_check06_010900 on SCHEDULE AT TIMESTAMP '2015-01-09 00:00:00'
    do
    begin

    DROP TABLE IF EXISTS 1_accountdb.t_check_20150106_level;
    CREATE TABLE IF not EXISTS 1_accountdb.t_check_20150106_level(
    `level` int(11) NOT NULL,
    `amount` int(11) NOT NULL,
    `date` datetime DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
    insert into 1_accountdb.t_check_20150106_level SELECT 1_accountdb.t_check_20150106.`level`,
    count(1_accountdb.t_check_20150106.`level`) as amount,
    TIMESTAMP(now()) as `date`
    from t_check_20150106 group by 1_accountdb.t_check_20150106.level;
    end |
    delimiter;

     数据库联查

    select * from ( SELECT
    phone_table.datetime,
    phone_table.phone,
    phone_table.systemtype,
    count(*) as amount
    FROM `phone_table` where phone_table.systemtype not like 'Intel(R)%' group by phone_table.phone ) as temp where temp.amount = 1 ORDER BY temp.systemtype;

  • 相关阅读:
    转载:CentOS7下部署Django项目详细操作步骤
    转载 js弹出框、对话框、提示框、弹窗总结
    python 博客开发之散乱笔记
    python 用 PIL 模块 画验证码
    RL
    c++ 基础知识 0001 const 知识2
    c++ 基础知识 0001 const 知识1
    神经网络的理论基础
    go set up on ubuntu
    ubuntu 上查看文件的内容,二进制形式展现
  • 原文地址:https://www.cnblogs.com/liulebao/p/3795329.html
Copyright © 2011-2022 走看看