mysql文档学习3.6
远程登录 -h IP地址
ctrl + d 退出 或 \q 或 quit
select version(); 当前版本
current_date当前日期 或curdate() 或 current_date()
SELECT name, birth, curdate(),(year(curdate())-year(birth)) - (right(curdate(),5)<right(birth,5)) as age from 表 ORDER BY name;
year 提取年部分 right(curdate(),5)提取右面的5位
month()月 month(curdate())
day() 天 或dayofmonth 意思是拿月来说的天数
dayofyear() 拿年来说的天
select date_add(curdate(),interval 1 year);
interval(间隔的意思) date_add 时间相加的函数
interval 数字 year或者month
mod(month(curdate()),12)
mod的意思也没用怎么明白! 意思就是前一个值是5,后面指定前面的参数最大是多少
now() 当前时间
user() 当前用户及链接地址
\c 重新开始
select distinct name from test;
distinct 去掉重复字段
order by 排序
binary(二进制意思) 强制区分大小写
相关文档:
基础部分
一、MySQL 获得当前日期时间 函数
1.1 获得当前日期+时间(date + time)函数:now()
mysql> select now();
+---------------------+
| now() |
+----------------- ......
2007-11-16 15:37
今天看着手册试了下,发现原来大数据导入导出是那么的轻松(不是很大,200多M的文本而以)
注意:如果发现MYSQL unknown command '\'这样的提示,则设置一下服务器的字符集,如:
mysql -uroot -ppasspass --default-character-set=utf8 databaseName <d:bakcup.sql
这样就不会报错了,^_^
导出 ......
如若转载本文,请注明原始出处:http://hi.baidu.com/hexiong/blog/item/e860e5dd9b0d3ae376c6381a.html
(hexiong@baidu or iihero@CSDN)
偶尔碰到有人问使用mysql命令行,老让人输入--default-character-set=gbk之类无聊的选项,让人烦。让人多输入了几个字符,确实有点不对劲。
加上有时候自己有时候DIY,很少在window ......
mysql停止命令
bin/mysqladmin -uroot -p shutdown
mysql启动命令
bin/mysqld_safe &
mysql 修改root密码
1.停止mysql服务
2.启动mysql服务时附加参数
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3.以root进入mysql
mysql -u root mysql
4.执行sql语句
mysql> UPDATE user S ......