日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

mysql8 修改密码_sysbench压测软件连接mysql8失败案例分析

發布時間:2025/3/21 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql8 修改密码_sysbench压测软件连接mysql8失败案例分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Mysql8出來有一段時間了,有很多新特性非常吸引人,于是就安裝好mysql-8.0.21數據庫嘗嘗鮮。數據庫是用二級制方式安裝的,安裝過程不復雜,如果想了解二進制安裝詳細過程,可以在文章下方留言,我會更新一篇文章,詳細介紹安裝過程和mysql8的參數。

mysql-8.0.21數據庫安裝好之后,就試著用sysbench建張10W記錄的表,測試一下降序索引特性。

首先在數據庫中創建了用于壓測的數據庫和用戶

create database sbtest;CREATE USER 'tony'@'%' IDENTIFIED BY 'tony';GRANT ALL ON *.* TO 'tony'@'%';flush privileges;

數據庫和用戶都創建好之后,就用sysbench插入測試數據

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:,認證組件“caching_sha2_password”沒有被加載,查了一下資料,原來在mysql8以后,用戶連接默認認證組件改為“caching_sha2_password”,而mysql5.7以前,默認的用戶認證組件為“mysql_native_password”。

既然知道了原因,就臨時將tony用戶的認證組件修改“mysql_native_password”,然后運行sysbench插入數據

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)

看到這里,有沒有想說點什么,密碼竟然變成空了,原來執行修改認證組件命令時,也將密碼置空了。

ALTER USER tony IDENTIFIED WITH mysql_native_password;

問題原因找到了,大家在生產操作時一定要注意,正確修改認證組件命令如下所示

alter user 'tony'@'%' identified with mysql_native_password by 'tony';flush privileges;

搞不好,就會出現大片應用連接不上數據庫的尷尬事情了。

總結

以上是生活随笔為你收集整理的mysql8 修改密码_sysbench压测软件连接mysql8失败案例分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。