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;

  • 相关阅读:
    web程序入门六(缓存)
    web程序入门五(http无状态)
    web程序入门四(webform常用成员)
    web程序入门三(分页)
    web程序入门二(webforms web窗体 aspx)
    CodeForce 710E
    CodeForce 710C Magic Odd Square
    CodeForce 710B Optimal Point on a Line
    CodeForce 710A King Moves
    HDU 4003
  • 原文地址:https://www.cnblogs.com/liulebao/p/3795329.html
Copyright © 2011-2022 走看看