Linux環境——MySQL安裝及配置(8.0版本)

虛擬機環境是Linux  Red Hat Enterprlse Linux (64位),本次安裝的是Mysql 8.0版本。html

因爲有經驗了,因此又弄了臺虛擬機練手,承接上一篇博客(http://www.javashuo.com/article/p-fdixvnhs-dm.htmlmysql

補充默認密碼的截圖sql

能夠在文件 【/var/log/mysqld.log】 中獲取,如圖:socket

[root@localhost116 mysql]# tail -100f /var/log/mysqld.log
2019-04-25T04:30:51.315933Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server in progress as process 25808
2019-04-25T04:30:55.323029Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fu#0YkCp)uv8 2019-04-25T04:30:57.526215Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server has completed
2019-04-25T04:30:59.986257Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.15) starting as process 26049
2019-04-25T04:31:00.635553Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-04-25T04:31:00.667243Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.15'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.
2019-04-25T04:31:00.765178Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

 這裏默認密碼就是   fu#0YkCp)uv8ide

訪問:post

[root@localhost107 mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.15

Copyright (c) 2000, 2019, 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>

 在【/etc/my.cnf】中修改配置,將default-authentication-plugin=mysql_native_password  去掉前面的#,以下圖:spa

重啓mysql服務rest

[root@localhost107 mysql]# service mysqld restart
中止 mysqld: [肯定]
正在啓動 mysqld: [肯定]
[root@localhost107 mysql]#

其餘命令:code

show variables like '%auth%';    #查看 default_authentication_plugin 的值
show variables like 'default_password_lifetime';    #查看 default_password_lifetime 的值
show variables like '%pass%';   #查看模糊查詢pass 屬性的值
select user,host,plugin from mysql.user;   #查看user表相關字段
set global validate_password_policy=0;      #設置 validate_password_policy 全局值爲0,可不遵循密碼規則
set global validate_password_length=4;   #設置 validate_password_length 密碼長度最少位數
flush privileges;   #修改生效
create user 用戶名 identified by '密碼';  #新增用戶及密碼
grant all on *.* to 用戶名;    #給用戶受權全部權限

特別注意:8.0版本中 validate_password.policy /  validate_password.length  最後一個連接符不是下劃線_而是點.否則會報錯,以下:server

mysql> set global validate_password_policy=0;
ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'

參考博客:http://www.javashuo.com/article/p-dnotvyqh-eq.html

相關文章
相關標籤/搜索