MySQL升级后从mysql_native_password认证模块更改为caching_sha2_password

MySQL 8.4 LTS 开始默认使用caching_sha2_password认证插件,来取代不太安全的mysql_native_password认证插件。网上很多的文章解决这个问题的方法,是启动MySQL的时候,加上--mysql-native-password=ON选项,以回退并继续使用mysql_native_password认证插件。然而,在MySQL 9.0以后,mysql_native_password认证插件不再被支持。所以更好的解决办法,还是彻底更改认证方式为caching_sha2_password

首先升级MySQL到8.4+后正常启动,默认认证模块会变更为caching_sha2_password

DROP USER 'foo'@'%';
CREATE USER 'foo'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON BAR.* TO 'foo'@'%';
FLUSH PRIVILEGES;

注意:
1. 只是 DELETE FROM mysql.user where User="foo"; FLUSH PRIVILEGES; 可能会导致CREATE USER失败,需要先DROP USER
2. 如果升级后无法登陆,可以启动MySQL的时候加上--skip-grant-tables以临时跳过认证。
3. 对于root用户,可以加上WITH GRANT OPTION

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

客户端这边,以PHP为例,需要确认支持caching_sha2_password认证插件。

<?php
phpinfo();
?>

会显示:

mysqlnd - Loaded plugins:
auth_plugin_caching_sha2_password

如果不支持,请升级版本。

狗日的微软,为何动我心爱的Zend(Php)

Microsoft Purchases Zend for $113 Million

At 10:00am today Zend issued a press release stating its intention to sell a controlling majority of its stock to Microsoft (MSFT). Previous rumours about a bidding war between Oracle and Microsoft had been played down in the Zend camp with zero output regarding the bidding war. Oracle have long been interested in the Zend Enterprise and have been keen to secure the PHP technology for use in an enterprise level database layer ensuring its position at the top of the ladder.

Microsoft Italy CEO Al Porfoli who spear headed the deal, rumoured to be worth US$113,000,000.00, says Microsoft has had Zend and the PHP scripting language in mind for some time. “We believe in making the next wave of Web2 applications as open as we can. A new range of Visual PHP products has been in beta testing by Zend and was recently used to create applications such as the new Zend Framework.

PHP Open Source developers are outraged at what they are calling a “sell out” by Zend as many have given their time freely in the development of the PHP language and the Zend engine. Developer Troy McKenzie is has taken this one step further and is filing a class action in a bid to salvage some value from the deal by what he is calling “free development for corporates”. Microsoft have issued a statement thanking the developers and the PHP community at large for their efforts in bringing the language to a point where it is Enterprise ready. Poroli goes on to say ” (microsoft) will put the hard work of the developers to good use. With a code base such as this, the new wave of Web2 applications is set to rolled out on all platforms”.

A possible renaming of the language has been touted but no official response has confirmed this. Some have quoted “MSSE (Microsoft Scripting Engine) as a possibility. New License agreements are being drawn up and several of the Zend products will such as the Zend Framework, Zend Encoder and the Zend Studio look set to hit our stores soon in a new range of development software that will add to the extensive Microsoft Development suite of applications

When approached, Zend declined to comment on the deal siting a new release would be issued when all transactions were complete.