怎么初始化MySQL数据库-创新互联

1)初始化随机密码    mysqld --initialize

成都创新互联公司是创新、创意、研发型一体的综合型网站建设公司,自成立以来公司不断探索创新,始终坚持为客户提供满意周到的服务,在本地打下了良好的口碑,在过去的10年时间我们累计服务了上千家以及全国政企客户,如成都护栏打桩机等企业单位,完善的项目管理流程,严格把控项目进度与质量监控加上过硬的技术实力获得客户的一致称誉。

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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

文章名称:怎么初始化MySQL数据库-创新互联
浏览地址:https://www.cdcxhl.com/article28/eepcp.html

成都网站建设公司_创新互联,为您提供响应式网站企业建站品牌网站制作定制网站软件开发小程序开发

广告

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

网站优化排名