mysql-5.7.24初始化数据库_MySQL5.7.28 初始化数据库
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文件中指定了數(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)初始化過
總結(jié)
以上是生活随笔為你收集整理的mysql-5.7.24初始化数据库_MySQL5.7.28 初始化数据库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 执行mysql查询_php中执行
- 下一篇: 为何控件删除不了_过不好又离不了的婚姻,