I\'m interested in mathematics and Daoism. Welcome to talk about these subjects with me.
分类: Mysql/postgreSQL
2015-10-27 14:40:28
Mac OS X下面启动服务
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
客户端登录命令:
mysql -h localhost -u tcenter -p
导出一个数据库的内容
./mysqldump -utcenter -p --database t1 > ~/t1.sql
导出一个表的内容
mysqldump -utcenter -p --database tcenter --tables
导出表结构
mysqldump -uroot -p -d db_name table_name > ./table_name.sql
创建用户
CREATE USER ‘tcenter’@‘localhost' IDENTIFIED BY ‘tcenter’;
给用户授权
grant all privileges on *.* to tcenter@localhost
数据库改名字
RENAME database olddbname TO newdbname
RENAME database t1 TO t1_old;
改字段名字
alter table web_blogcomment change updatetime lastUpdateTime datetime;
添加字段
alter table table_name add field_name varchar(10);
删除主键
alter table tbname drop primary key;
添加主键
alter table tbname add primary key(字段1,2,3);
设置utf-8编码格式
alter table student_words change word_value word_value varchar(100) CHARACTER SET utf8;
查看数据库编码
show variables like 'char%';
general log的使用
show variables like 'general_log';
set global general_log=on;
查询某一些天的某个数据.其中operate_time是timestamp类型
SELECT * FROM t_operate_log WHERE operate_time >= TIMESTAMP("2017-03-16", "YYYY-MM-DD")
ORDER BY operate_time DESC