工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表分类:mysql/db

Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client

set password for user1@"localhost"=old_password('yourPassword');

UPDATE user SET Password = OLD_PASSWORD('newpwd')   WHERE  User = 'usrname';

flush privileges;

MYSQL 帮助:

A.2.3 Client does not support authentication protocol

MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to it with an older client may fail with the following message:

shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client

To solve this problem, you should use one of the following approaches:

  • Upgrade all client programs to use a 4.1.1 or newer client library.
  • When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.
  • Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function:
    mysql> SET PASSWORD FOR
        -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
    Alternatively, use UPDATE and FLUSH PRIVILEGES:
    mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
        -> WHERE Host = 'some_host' AND User = 'some_user';
    mysql> FLUSH PRIVILEGES;
    Substitute the password you want to use for ``newpwd'' in the preceding examples. MySQL cannot tell you what the original password was, so you'll need to pick a new one.
  • Tell the server to use the older password hashing algorithm:
    1. Start mysqld with the --old-passwords option.
    2. Assign an old-format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query:
      mysql> SELECT Host, User, Password FROM mysql.user
          -> WHERE LENGTH(Password) > 16;
      For each account record displayed by the query, use the Host and User values and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier.

For additional background on password hashing and authentication, see section 5.5.9 Password Hashing in MySQL 4.1.

mysql processlist

mysqladmin -uroot -p proc

mysql -e "show processlist"

Duplicate entry `1-0` for key 1

检查主键ID或索引的ID,如果类型是primary,就会这样.改为index

mysql.5.0.45

使用Google的开源TCMalloc库,提高MySQL在高并发情况下的性能(转)

TCMalloc(Thread-Caching Malloc)是google开发的开源工具──“google-perftools”中的成员。与标准的glibc库的malloc相比,TCMalloc在内存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服务器在高并发情况下的性能,降低系统负载。

  TCMalloc的实现原理和测试报告请见一篇文章:《TCMalloc:线程缓存的Malloc

为MySQL添加TCMalloc库的安装步骤(Linux环境):

  1、64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提供了基本的堆栈辗转开解功能,其中包括用于输出堆栈跟踪的API、用于以编程方式辗转开解堆栈的API以及支持C++异常处理机制的API。

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
tar zxvf libunwind-0.99-alpha.tar.gz
cd libunwind-0.99-alpha/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install



  2、安装google-perftools:

wget http://google-perftools.googlecode.com/files/google-perftools-0.97.tar.gz
tar zxvf google-perftools-0.97.tar.gz
cd google-perftools-0.97/
./configure
make && make install

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig



  3、修改MySQL启动脚本(根据你的MySQL安装位置而定):

vi /usr/local/mysql/bin/mysqld_safe


  在# executing mysqld_safe的下一行,加上:

引用
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so


  保存后退出,然后重启MySQL服务器。


  4、使用lsof命令查看tcmalloc是否起效:

/usr/sbin/lsof -n | grep tcmalloc


  如果发现以下信息,说明tcmalloc已经起效:
  mysqld    10847   mysql  mem       REG        8,5  1203756   20484960 /usr/local/lib/libtcmalloc.so.0.0.0  

原文 http://blog.s135.com/read.php/349.htm

 

----------------------------

--with-mysqld-ldflags="-ltcmalloc -lunwind"

Field 'id' doesn't have a default value问题解决方法

MySQL 5中,出现错误提示:
Field 'id' doesn't have a default value

解决方法一:

打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

修改为

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后重启MYSQL


解决方法二:
MySQL 5 uses a strict mode which needs to be disabled.
In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.

使用distinct在mysql中查询多条不重复记录值的解决办法

在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值。其原因是distinct只能返回它的目标字段,而无法返回其它字段,这个问题让我困扰了很久,用distinct不能解决的话,我只有用二重循环查询来解决,而这样对于一个数据量非常大的站来说,无疑是会直接影响到效率的。所以我花了很多时间来研究这个问题,网上也查不到解决方案,期间把容容拉来帮忙,结果是我们两人都郁闷了。。。。。。。。。

下面先来看看例子:

    table
  id name
  1 a
  2 b
  3 c
  4 c
  5 b

库结构大概这样,这只是一个简单的例子,实际情况会复杂得多。

比如我想用一条语句查询得到name不重复的所有数据,那就必须使用distinct去掉多余的重复记录。

select distinct name from table
得到的结果是:

  name
  a
  b
  c

好像达到效果了,可是,我想要得到的是id值呢?改一下查询语句吧:

select distinct name, id from table

结果会是:

  id name
  1 a
  2 b
  3 c
  4 c
  5 b

distinct怎么没起作用?作用是起了的,不过他同时作用了两个字段,也就是必须得id与name都相同的才会被排除。。。。。。。

我们再改改查询语句:

select id, distinct name from table

很遗憾,除了错误信息你什么也得不到,distinct必须放在开头。难到不能把distinct放到where条件里?能,照样报错。。。。。。。

很麻烦吧?确实,费尽心思都没能解决这个问题。没办法,继续找人问。

拉住公司里一JAVA程序员,他给我演示了oracle里使用distinct之后,也没找到mysql里的解决方案,最后下班之前他建议我试试group by。

试了半天,也不行,最后在mysql手册里找到一个用法,用group_concat(distinct name)配合group by name实现了我所需要的功能,兴奋,天佑我也,赶快试试。

报错。。。。。。。。。。。。郁闷。。。。。。。连mysql手册也跟我过不去,先给了我希望,然后又把我推向失望,好狠哪。。。。

再仔细一查,group_concat函数是4.1支持,晕,我4.0的。没办法,升级,升完级一试,成功。。。。。。

终于搞定了,不过这样一来,又必须要求客户也升级了。

突然灵机一闪,既然可以使用group_concat函数,那其它函数能行吗?

赶紧用count函数一试,成功,我。。。。。。。想哭啊,费了这么多工夫。。。。。。。。原来就这么简单。。。。。。

现在将完整语句放出:

select *, count(distinct name) from table group by name

结果:

  id name count(distinct name)
  1 a 1
  2 b 1
  3 c 1

最后一项是多余的,不用管就行了,目的达到。。。。。

唉,原来mysql这么笨,轻轻一下就把他骗过去了,郁闷也就我吧(对了,还有容容那家伙),现在拿出来希望大家不要被这问题折腾。

哦,对,再顺便说一句,group by 必须放在 order by 和 limit之前,不然会报错,差不多了,发给容容放网站上去,我继续忙碌。。。。。。

-----------------------------------------------------------------------------------------


更郁闷的事情发生了,在准备提交时容容发现,有更简单的解决方法。。。。。。

select id, name from table group by name

看来对mysql的了解还是太肤浅了,不怕被笑话,发出来让大家别犯同样的错误。。。。。。

by 索尔

原文 http://www.phpv.net/html/1501.html

 

这篇文章帮了我个很大的忙,帮我解决了我想了一个下午和晚上都没解决的问题,就一个group by name给解决了."看来对mysql的了解还是太肤浅了"

多表关联查询

mysql> SELECT * FROM table1,table2 WHERE table1.id=table2.id;
mysql> SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;
mysql> SELECT * FROM table1 LEFT JOIN table2 USING (id);
mysql> SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id
    ->          LEFT JOIN table3 ON table2.id=table3.id;
mysql> SELECT * FROM table1 USE INDEX (key1,key2)
    ->          WHERE key1=1 AND key2=2 AND key3=3;
mysql> SELECT * FROM table1 IGNORE INDEX (key3)
    ->          WHERE key1=1 AND key2=2 AND key3=3;

Specified key was too long; max key length is 1000 bytes

这两天在玩wiki,安装mediawiki时,提示这个

Specified key was too long; max key length is 1000 bytes

原因是建库是是用utf8,就会有这个提示,后改为latin1就一切正常了

还有,在mediawiki的新版中,数据库都是用InnoDB,而且在安装时没得选择,觉得不爽.得手工修改.

测试了以下 mediawiki、CooCooWakka、dokuwiki 几个wiki,今天才比较有找到感觉,不过,和我想要实现的功能相差比较大,开始也不太了解wiki

 

引用

mediawiki——最大的开源Wiki引擎,被维基百科全书及大量站点广泛采用。功能比较完善,支持多语种,後台功能稍弱,运行速度不快。持续更新中。支持中文,大陆使用最多。
MoinMoin——基于Python语言的wiki引擎,具有模块化设计及较好的灵活性。支持中文,大陆有一些使用。
PhpWiki——以流行的PHP语言写成,前身为UseModWiki并扩展了很多特性。
aspWiki——一个asp写成的wiki开源引擎。
OddMuseWiki——UseModWiki完全的後继者。
UseModWiki——一个Perl写成的wiki引擎
TwikiClone——一个强大的wiki引擎,可换肤。Perl写成,适合大公司的内部网。
TikiWiki——无所不包的内容管理系统,以及wiki功能。
PmWiki——基于PHP,易于安装、管理,特性不错。大陆有一些使用。
WakkaWiki——评价不错的wiki,有一系列延伸版本。其中CooCooWakka支持中文。
TWiki----a very good wiki, using perl cgi

 

Records:5912345678