Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to initialize MySQL database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1) initialize random password mysqld-initialize

[root@host-172-16-61-102bin] #. / 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

The generated password is: +: NoRLu2kwhd

The above directive, which reads the configuration file / etc/my.cnf by default, requires that the address of the database is specified in the / etc/my.cnf file and a password for the root user is generated. The following parameters can be set

-- user=mysql / / generate the password of the specified user

-- datadir=/opt/mysql/mysql/data / / specify the address of the generated database data

-- defaults-file=/opt/mysql/mysql/etc/my.cnf// specifies the read configuration file instead of the default configuration

2) initialize the empty password mysqld-initialize-insecure

Start the mysqld service. / mysqld-- user=root

Create password

[root@host-172-16-61-102bin] # mysql-uroot-p

/ / prompt for password input and enter directly

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.

/ / create a password for root

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

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

MySQL [(none)] > quit

Note: an error occurred in the execution of "mysqld-initialize". Prompt "initialize specified but the data directory has files in it. Aborting" to the effect that there is a file under the address of the / opt/mysql/mysql/data database, resulting in the database cannot be initialized. At this time, you can go to the directory and delete all the data, indicating that it has been initialized before.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report