1、Error Code: 1044 - Access denied for user 'root'@'localhost' to database 'information_schema'Query
今天在导入数据库的时候出现了如下的问题:
Error Code: 1044 - Access denied for user 'root'@'localhost' to database 'information_schema'Query
以前没有遇到过这种问题,在度娘上找了下,唉啊,都是什么鬼啊。 算了出了问题还是自己找吧。仔细分析导入时候的报错信息:对于用户localhost对数据库informationschema的查询是拒绝访问的。 可是我并没有要访问informationschema这个数据库啊,然后就看了一下我导入的过程,原来是把sql文件导入到information_schema数据库了,我擦,这不是我想要的啊,于是在本地新建一个数据库,然后导入,然后就可以了。。。
遇到问题还是要先自己分析,找度娘还不如自己静静看 log日志来的快呢。。。。。
2、mysql自增长为什么会每次加2的原因【转】
今天利用一个临时表自增id做操作的时候,查看数据发现自增是每次加2的。。。不知道是谁设置的这个。。
show variables like '%increment%'; +-------------------------------+-------+ | Variable_name | Value | +-------------------------------+-------+ | auto_increment_increment | 2 | | auto_increment_offset | 1 | | div_precision_increment | 4 | | innodb_autoextend_increment | 8 | | ndb_autoincrement_prefetch_sz | 32 | +-------------------------------+-------+ 5 rows in set (0.01 sec) set auto_increment_increment = 1和set @@auto_increment_increment = 1 如果想永久性的改回为1,在my.cnf or my.ini中查找这个field,然后修改,然后restart MySQL.
3、使用Navicat for MySQ导出日期时间类型数据,存在格式不同的情况,给后续的导入带来麻烦,其实在导出的时候格式化一下导出的日期时间就好了。
没使用时间格式前导出的数据格式如下:
使用如下sql格式化一下时间就可以了:
SELECT user_id, login_id, opt, type, loginip, DATE_FORMAT(`timestamp`,"%Y-%m-%d %H:%i:%s") as `test` FROM stat_login ORDER BY `timestamp` LIMIT 10;
导出数据的时间与日期如下: