mysql笔记点点点。。。

一直使用mysqlfront
很多命令懒得记
Note一下吧

一、CREATE TABLE 方法

整表复制 # create table 新表 select * from 旧表;
结构复制 # create table 新表 select * from 旧表 where 1<>1;

二、INSERT INTO 方法

得到建表语句 # show create table 旧表;
新建表
复制数据到新表 # insert into 新表 select * into from 旧表;

今天好不容敲了一些命令,copy过来
create TABLE test_products select * from products where 1<>1

insert into test_products (ProductID, PanelKind, GBID, ProductName, ReplaceModel, Model, SimilarModel,
Standard, Certificate, Price, Description, Class1, Class2, EncapsulatStyle, Remark, PDFID,
ProducingArea, IsPiece, EncapsulatSize, ForUse, TemperatureLow, TemperatureHeigh, FileName,
IsForMilitary, Modifier, UpdateTime, Operator, CreateTime, IsInspect, InspectTime, Inspector)
select ProductID, TemplateID, GBID , ProductName, ReplaceModel, Model, SimilarModel, Standard,
Certificate, Price, Description, Class1, Class2, PackagingStyle, Comments, PDFID, ProducingArea,
IsPiece, PackageSize, MainUse, WorkTempL, WorkTempH, Brand, IsMilitary, Modifier, UpdateTime,
Operator, CreateTime, IsInspect, InspectTime, Inspector from products limit 1000

insert into test_products select * from products ORDER by ProductID limit 1000

select class1,class1,class2 from cec_products ORDER by ProductID  limit 1000

。。。。。。。

 

//Mysql的日期运算
select now(),user(),version(),current_date

select * from province where MONTH(CreateTime)=8 AND DAYOFMONTH(CreateTime)=6

select CURRENT_TIMESTAMP

SELECT TO_DAYS(CURRENT_date)

//算出某人的当前年纪
select FLOOR((TO_DAYS(CURRENT_DATE )- TO_DAYS('1968-06-18') )/365)

//日期加减
select CURRENT_TIMESTAMP , date_add(CURRENT_TIMESTAMP ,interval 10 year)

select CURRENT_TIMESTAMP , DATE_SUB(CURRENT_TIMESTAMP ,interval 10 year)

//创建临时表
create TEMPORARY TABLE yyy select * from province

select * from yyy

DROP table yyy

//检查是否存在表

select count(*) from tb1_name

select * from tb1_name where 1=0

//设null值

update linkmanformanu set Remark =NULL where Remark  ='null'

 

 MySQL的Password连接问题


似乎MySQL从4.1开始升级了密码加密的杂凑算法,当我从MySQL4.0.17升级到最新版本后,Web应用的认证接口从此无法通过密码验证,尝试修改MySQL密码,问题依旧。通过网上搜索,发现这早已不是什么新问题,不过还是总结一下吧:

  1. 使用旧密码模式
    MySQL从4.1.x开始默认使用40位长的Hash串,而Web应用接口正在使用支持短Hash串的MySQL库,这造成了密码验证的兼容性问题。强制MySQL使用旧密码模式可以解决,方法是使用OLD_PASSWORD() 函数:

    mysql> SET PASSWORD for john@localhost=OLD_PASSWORD('abc123');

     

    可以在MySQL启动脚本中加入--old-passwords选项,实现系统级修改。

  2. 升级应用程序
    上一种方法不是最佳,使用短Hash降低了数据库安全性,升级应用程序兼容最新的MySQL库才是解决之道。例如重新编译或升级PHP,如PHP 5.0.x;重新编译或升级Perl DBI等。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值