日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

CentOS下yum安装MySQL8.0

發(fā)布時(shí)間:2023/12/29 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS下yum安装MySQL8.0 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

目錄

  • yum安裝MySQL8
    • 安裝MySQL8.0資源庫
    • 安裝MySQL8.0
    • 啟動(dòng)MySQL并配置開機(jī)自啟
    • 查看默認(rèn)密碼并重置
  • 使用MySQL8.0踩的坑
    • 授權(quán)方式改變
    • 無法遠(yuǎn)程連接
    • 加密規(guī)則的改變
    • update修改密碼,密碼字段名稱更改

yum安裝MySQL8

安裝MySQL8.0資源庫

yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安裝MySQL8.0

yum install mysql-community-server

啟動(dòng)MySQL并配置開機(jī)自啟

systemctl start mysqld systemctl enable mysqld

查看默認(rèn)密碼并重置

  • 查看密碼
grep 'temporary password' /var/log/mysqld.log

  • 登錄并重置密碼
mysql -pt&ki3u&+ib7X mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

這個(gè)與validate_password_policy的值有關(guān), mysql8.0更改了validate_password_policy相關(guān)的配置, 這跟Mysql5.7有點(diǎn)不一樣

  • 修改密碼校驗(yàn)規(guī)則與密碼長度
mysql> set global validate_password.policy=0; Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password.length=1; Query OK, 0 rows affected (0.00 sec)
  • 繼續(xù)修改密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.03 sec)
  • 退出后重新登錄
[root@zabbix-server ~]# mysql -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.22 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.22 | +-----------+ 1 row in set (0.00 sec)

使用MySQL8.0踩的坑

授權(quán)方式改變

  • mysql5.7
mysql> grant all privileges on *.* to 'kevin'@'%' ;
  • mysql8.0
mysql> grant all privileges on *.* to 'kevin'@'%' with grant option;

無法遠(yuǎn)程連接

MySQL8.0默認(rèn)是不能使用root賬戶遠(yuǎn)程登錄的

  • 修改為可以遠(yuǎn)程登錄
mysql> update mysql.user set host='%' where user="root"; mysql> flush privileges;

加密規(guī)則的改變

mysql8 之前的版本中加密規(guī)則是mysql_native_password, 而在mysql8之后,加密規(guī)則是caching_sha2_password

使用navicat進(jìn)行mysql登錄時(shí)出現(xiàn)彈窗報(bào)錯(cuò)

修改方式一是:升級(jí)navicat驅(qū)動(dòng),二是:把MySQL用戶登錄密碼加密規(guī)則還原成mysql_native_password

#修改加密規(guī)則 mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.16 sec)#更新一下用戶的密碼 mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.08 sec)#刷新權(quán)限 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.03 sec)

update修改密碼,密碼字段名稱更改

mysql>update user set authentication_string=password("root") where user='root' and host='localhost';

總結(jié)

以上是生活随笔為你收集整理的CentOS下yum安装MySQL8.0的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。