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

歡迎訪問 生活随笔!

生活随笔

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

数据库

MySQL学习笔记(六)MySQL8.0 配置笔记

發(fā)布時間:2025/6/17 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL学习笔记(六)MySQL8.0 配置笔记 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

今天把數(shù)據(jù)庫配置文件修改了,結(jié)果重啟不了了

需要使用 mysqld?--initialize?或 mysqld?--initialize-insecure 命令來初始化數(shù)據(jù)庫

1、mysqld?--initialize-insecure可以不生成隨機密碼,設(shè)置數(shù)據(jù)庫空密碼。

2、安裝Mysql時默認(rèn)使用的是mysqld?--initialize命令。這個命令也會生成一個隨機密碼。改密碼保存在了Mysql的日志文件中

3、通過配置文件查看日志文件路徑? /etc/mysql/mysql.conf.d/mysqld.cnf。打開該文件,可以看到mysql的datadir和log文件等的配置信息

# 日志文件路徑 log-error = /var/log/mysql/error.log

4、打開log文件并搜索 password ,可以看到密碼

5、登錄數(shù)據(jù)庫

使用找到的隨機密碼登錄mysql,首次登錄后,mysql要比必須修改默認(rèn)密碼,否則不能執(zhí)行任何其他數(shù)據(jù)庫操作,這樣體現(xiàn)了不斷增強的Mysql安全性。

這里會有幾個問題

1、提示必須的修改密碼

2、8.0修改密碼命令

ALTER user 'root'@'localhost' IDENTIFIED BY 'Tinywan123456'

  

創(chuàng)建新用戶
MySQL8.0取消了直接grant創(chuàng)建用戶的語法,只能先create user再grant,因此創(chuàng)建root如下

mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -ADatabase changed mysql> create user user001@'localhost' identified by '112233'; Query OK, 0 rows affected (0.01 sec)mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)mysql> create user user002@'%' identified by '112233'; Query OK, 0 rows affected (0.01 sec)mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)

測試user001遠(yuǎn)程登錄

$ mysql -u user001 -p112233 -h 159.11.213.20 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 35 Server version: 8.0.12 MySQL Community Server - GPLCopyright (c) 2000, 2018, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | +--------------------+ 1 row in set (0.00 sec)mysql>

?

Navicat Premium?遠(yuǎn)程連接不了

提示一下信息

如何解決:

1、先通過命令行進(jìn)入mysql的root賬戶

mysql -h localhost -uroot -pTinywan123456

2、更改加密方式

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.10 sec)

3、修改密碼

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; Query OK, 0 rows affected (0.35 sec)

4、清除緩存

mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.28 sec)

5、重新連接Navicat Premium? 可以正常連接成功  

  

參考:

1、https://www.jb51.net/article/140282.htm

2、https://www.jb51.net/article/47727.htm

3、https://blog.csdn.net/zonghua521/article/details/78198052

4、https://blog.csdn.net/tr1912/article/details/81271851 

總結(jié)

以上是生活随笔為你收集整理的MySQL学习笔记(六)MySQL8.0 配置笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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