mysql 常用基础
2014-06-18 20:51
288 查看
登录命令 -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;
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;
相关文章推荐
- mysql -- 基础 -- 常用工具
- MySQL 基础常用命令
- Mysql学习总结(4)——MySql基础知识、存储引擎与常用数据类型
- MySQL 常用基础命令
- 一、安装mysql、mysql基础、mysql常用命令、数据表以及数据类型
- mysql -- 基础 -- 常用命令
- mysql常用基础操作语法(二)~~对表的增删改操作【命令行模式】
- MySQL 基础常用命令
- MySQL 基础常用命令
- mysql 入门基础(7)—sql编程常用函数
- MySQL 基础常用命令
- MySQL 基础常用命令
- MySql基础教程(常用命令)
- Mysql学习总结(4)——MySql基础知识、存储引擎与常用数据类型
- MySQL 基础常用命令
- mysql常用基础命令
- Mysql基础原理和常用命令使用
- MySQL 基础常用命令
- MySQL学习笔记——常用基础操作
- mysql常用基础操作语法(一)~~对库的操作【命令行模式】