mysql 經常使用基礎

登陸命令 -h遠程IP地址 -u用戶名 -p密碼 -P端口php

mysql -h127.0.0.1 -uroot -p21313 -P3306mysql

新建用戶sql

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

刷新權限ide

flush privileges;get

建立數據庫it

create database 數據庫名;table

顯示數據庫登錄

show databases;date

切換數據庫

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 ( SELECTphone_table.datetime,phone_table.phone,phone_table.systemtype,count(*) as amountFROM `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;

相關文章
相關標籤/搜索