怎么初始化MySQL数据库

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数据库地址下有文件,导致无法初始化数据库,这个时候,可以进入到该目录,将所有的数据删除,说明之前已经初始化过

当前题目:怎么初始化MySQL数据库
URL链接:https://www.cdcxhl.com/article0/iiopoo.html

成都网站建设公司_创新互联,为您提供微信公众号用户体验企业网站制作定制开发App开发动态网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

商城网站建设