常用mysql语句

2018-10-16 19:09:45       xhs
改密码
mysqladmin -uroot -p123456 password 123 

建数据库
CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;

\G 垂直显示
SELECT report_id FROM `weekly_report_content` WHERE report_id IN (381395,381437,380576,381359,381472)\G

#备份
#备份某个库(cmdb)某些表(cmdb_cluster_hosts,多个空格隔开)的数据
mysqldump -h192.168.3.97 -t cmdb -u root -proot --tables cmdb_cluster_hosts > /root/cmdb_cluster_hosts.sql
-P是端口

#导入
mysql -uroot -p test < test.sql

#格式化时间
FROM_UNIXTIME(v.visit_time, '%Y-%m-%d') AS visit_time
select request_data, FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%s') AS c_time from mytable order by id desc limit 10;

查总数是COUNT,但总和是 SUM !!! 

发表评论