您好,登錄后才能下訂單哦!
1)初始化隨機密碼????mysqld --initialize?
[root@host-172-16-61-102 bin]# ./mysqld --initialize
2020-02-15T07:01:38.309015Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-02-15T07:01:38.309069Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-02-15T07:01:38.497402Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-02-15T07:01:38.541219Z 0 [Warning] InnoDB: Creating foreign key constraint system?
tables.
2020-02-15T07:01:38.553509Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 02fb69c1-4fc1-11ea-8b4e-fa163d34f78d.
2020-02-15T07:01:38.556591Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-02-15T07:01:38.980429Z 0 [Warning] CA certificate ca.pem is self signed.
2020-02-15T07:01:39.723869Z 1 [Note] A temporary password is generated for root@localhost: +:NoRLu2kwhd
生成的密碼是:+:NoRLu2kwhd
以上的指令,默認讀取配置文件/etc/my.cnf,需要/etc/my.cnf文件中指定了數據庫的地址,并且生成一個root用戶的密碼,還有如下的參數可以設置
--user=mysql? //生成指定用戶的密碼
--datadir=/opt/mysql/mysql/data? //指定生成的數據庫數據地址
--defaults-file=/opt/mysql/mysql/etc/my.cnf//指定讀取的配置文件,取代默認的配置
2)初始化空密碼????mysqld --initialize-insecure
啟動mysqld服務 ./mysqld --user=root
創建密碼
[root@host-172-16-61-102 bin]# mysql -uroot -p
//提示密碼輸入,直接回車
Welcome to the MariaDB monitor.? Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.28 MySQL xxx
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
//為root創建密碼
MySQL [(none)]> set password = password("root");
Query OK, 0 rows affected, 1 warning (0.00 sec)
MySQL [(none)]> quit
注意:執行“mysqld? --initialize”報錯了。提示“initialize specified but the data directory has files in it. Aborting”,大意是提示/opt/mysql/mysql/data數據庫地址下有文件,導致無法初始化數據庫,這個時候,可以進入到該目錄,將所有的數據刪除,說明之前已經初始化過
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。