怎么初始化MySQL數(shù)據(jù)庫

1)初始化隨機密碼    MySQLd --initialize 

創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的吉林網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

[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文件中指定了數(shù)據(jù)庫的地址,并且生成一個root用戶的密碼,還有如下的參數(shù)可以設(shè)置

--user=mysql  //生成指定用戶的密碼

--datadir=/opt/mysql/mysql/data  //指定生成的數(shù)據(jù)庫數(shù)據(jù)地址

--defaults-file=/opt/mysql/mysql/etc/my.cnf//指定讀取的配置文件,取代默認的配置

2)初始化空密碼    mysqld --initialize-insecure

啟動mysqld服務(wù) ./mysqld --user=root

創(chuàng)建密碼

[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創(chuàng)建密碼

MySQL [(none)]> set password = password("root");

Query OK, 0 rows affected, 1 warning (0.00 sec)

MySQL [(none)]> quit

注意:執(zhí)行“mysqld  --initialize”報錯了。提示“initialize specified but the data directory has files in it. Aborting”,大意是提示/opt/mysql/mysql/data數(shù)據(jù)庫地址下有文件,導(dǎo)致無法初始化數(shù)據(jù)庫,這個時候,可以進入到該目錄,將所有的數(shù)據(jù)刪除,說明之前已經(jīng)初始化過

當前題目:怎么初始化MySQL數(shù)據(jù)庫
URL鏈接:http://muchs.cn/article0/iiopoo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、用戶體驗、企業(yè)網(wǎng)站制作、定制開發(fā)、App開發(fā)動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)