mysql8 修改密码_sysbench压测软件连接mysql8失败案例分析
Mysql8出來有一段時間了,有很多新特性非常吸引人,于是就安裝好mysql-8.0.21數(shù)據(jù)庫嘗嘗鮮。數(shù)據(jù)庫是用二級制方式安裝的,安裝過程不復(fù)雜,如果想了解二進(jìn)制安裝詳細(xì)過程,可以在文章下方留言,我會更新一篇文章,詳細(xì)介紹安裝過程和mysql8的參數(shù)。
mysql-8.0.21數(shù)據(jù)庫安裝好之后,就試著用sysbench建張10W記錄的表,測試一下降序索引特性。
首先在數(shù)據(jù)庫中創(chuàng)建了用于壓測的數(shù)據(jù)庫和用戶
create database sbtest;CREATE USER 'tony'@'%' IDENTIFIED BY 'tony';GRANT ALL ON *.* TO 'tony'@'%';flush privileges;數(shù)據(jù)庫和用戶都創(chuàng)建好之后,就用sysbench插入測試數(shù)據(jù)
sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-socket=/data/mysql/mysql8/run/3308/mysql.sock --mysql-user=tony --mysql-password='tony' --mysql-db=sbtest --oltp-test-mode=complex --oltp-tables-count=1 --oltp-table-size=100000 --threads=128 --oltp-nontrx-mode=select --oltp-read-only=off --max-time=120 --report-interval=5 prepareFATAL: unable to connect to MySQL server on socket '/data/mysql/mysql8/run/3308/mysql.sock', aborting...FATAL: error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directoryFATAL: `prepare' function failed: /usr/share/sysbench/tests/include/oltp_legacy/common.lua:111: Failed to connect to the database可是報錯了,FATAL: error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded:,認(rèn)證組件“caching_sha2_password”沒有被加載,查了一下資料,原來在mysql8以后,用戶連接默認(rèn)認(rèn)證組件改為“caching_sha2_password”,而mysql5.7以前,默認(rèn)的用戶認(rèn)證組件為“mysql_native_password”。
既然知道了原因,就臨時將tony用戶的認(rèn)證組件修改“mysql_native_password”,然后運(yùn)行sysbench插入數(shù)據(jù)
ALTER USER tony IDENTIFIED WITH mysql_native_password;flush privileges;[mysql@mysql ~]$ sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-socket=/data/mysql/mysql8/run/3308/mysql.sock --mysql-user=tony --mysql-password='tony' --mysql-db=sbtest --oltp-test-mode=complex --oltp-tables-count=1 --oltp-table-size=100000 --threads=128 --oltp-nontrx-mode=select --oltp-read-only=off --max-time=120 --report-interval=5 prepareWARNING: --max-time is deprecated, use --time insteadsysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)FATAL: unable to connect to MySQL server on socket '/data/mysql/mysql8/run/3308/mysql.sock', aborting...FATAL: error 1045: Access denied for user 'tony'@'localhost' (using password: YES)FATAL: `prepare' function failed: /usr/share/sysbench/tests/include/oltp_legacy/common.lua:111: Failed to connect to the database竟然還報錯,這次是連接不上庫,為什么呢,檢查用戶是否正常
[root@localhost] 16:54:13 [performance_schema]>select user,host,plugin from mysql.user where user='tony';+------+------+-----------------------+| user | host | plugin |+------+------+-----------------------+| tony | % | mysql_native_password |+------+------+-----------------------+1 row in set (0.00 sec)tony用戶的host是不限制IP段了,plugin也修改成mysql_native_password,難道是密碼不對
[root@localhost] 16:56:08 [performance_schema]>select user,host,plugin,authentication_string from mysql.user where user='tony';+------+------+-----------------------+-----------------------+| user | host | plugin | authentication_string |+------+------+-----------------------+-----------------------+| tony | % | mysql_native_password | |+------+------+-----------------------+-----------------------+1 row in set (0.71 sec)看到這里,有沒有想說點什么,密碼竟然變成空了,原來執(zhí)行修改認(rèn)證組件命令時,也將密碼置空了。
ALTER USER tony IDENTIFIED WITH mysql_native_password;問題原因找到了,大家在生產(chǎn)操作時一定要注意,正確修改認(rèn)證組件命令如下所示
alter user 'tony'@'%' identified with mysql_native_password by 'tony';flush privileges;搞不好,就會出現(xiàn)大片應(yīng)用連接不上數(shù)據(jù)庫的尷尬事情了。
總結(jié)
以上是生活随笔為你收集整理的mysql8 修改密码_sysbench压测软件连接mysql8失败案例分析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python链接mysql 判断是否成功
- 下一篇: 用python做毕业设计小程序_用Pyt