零散语句备忘
赋权Contos6.5 chmod 777 *.sh
truncate `xxx`; //删除表数据 truncate table student; var LOGINNAME = $("input[name='logname']").val();//取值 param.setLoginTime(new Timestamp(System.currentTimeMillis())); //Timestamp时间戳 import java.sql.Timestamp; insert into student(name,age,gender,telephone,email, classId,regDate,className)values ('小花','22','男','11111111','123123@qq.com', '11','2017-06-14','s24'); select to_days(CURRENT_DATE,'yyyy-MM-dd hh24:MI:ss') from student; select * from student where 1=1 and name like '%小花%' and regDate between '2017-06-14' and '2017-06-14' order by id; mysql安全模式 因为没有where条件而不能跟新处理方法
show variables like 'SQL_SAFE_UPDATES';
SET SQL_SAFE_UPDATES = 0;
SELECT TO_CHAR(CURRENT_DATE, 'yyyy-MM-dd hh:MM:ss')
1,2,3分割
/* Navicat MySQL Data Transfer Source Server : localhost Source Server Version : 50718 Source Host : localhost:3306 Source Database : testd Target Server Type : MYSQL Target Server Version : 50718 File Encoding : 65001 Date: 2018-01-30 08:55:56 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for dept -- ---------------------------- DROP TABLE IF EXISTS `dept`; CREATE TABLE `dept` ( `id` int(11) NOT NULL AUTO_INCREMENT, `deptname` varchar(50) DEFAULT NULL, `tid` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of dept -- ---------------------------- INSERT INTO `dept` VALUES ('1', '营销部', '1,2'); INSERT INTO `dept` VALUES ('2', '市场', '2'); -- ---------------------------- -- Table structure for type -- ---------------------------- DROP TABLE IF EXISTS `type`; CREATE TABLE `type` ( `tid` int(11) NOT NULL AUTO_INCREMENT, `tname` varchar(50) DEFAULT NULL, PRIMARY KEY (`tid`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of type -- ---------------------------- INSERT INTO `type` VALUES ('1', 'admin'); INSERT INTO `type` VALUES ('2', 'user');
select id,deptname,tname from dept d INNER join type t on
find_in_set('1',d.tid)= t.tId or find_in_set('2',d.tid) = t.tid or find_in_set('3',d.tid)
mysqladmin命令
- 格式如下(其中,USER为用户名,PASSWORD为新密码):
mysqladmin -u USER -p password PASSWORD该命令之后会提示输入原密码,输入正确后即可修改。
例如,设置root用户的密码为123456,则mysqladmin -u root -p password 123456 -
UPDATE user 语句
这种方式必须是先用root帐户登入mysql,然后执行:UPDATE user SET password=PASSWORD('123456') WHERE user='root';
FLUSH PRIVILEGES; -
SET PASSWORD 语句
这种方式也需要先用root命令登入mysql,然后执行:SET PASSWORD FOR root=PASSWORD('123456');
#{}与${}的区别可以简单总结如下:
- #{}将传入的参数当成一个字符串,会给传入的参数加一个双引号
- ${}将传入的参数直接显示生成在sql中,不会添加引号
- #{}能够很大程度上防止sql注入,${}无法防止sql注入
${}在预编译之前已经被变量替换了,这会存在sql注入的风险。