A practical record of an accident caused by MySQL startup

A practical record of an accident caused by MySQL startup

MySQL` starts with a port being listened to, but the service is not fully started.

background

When MySQL starts, it will initialize the database for the first time. After MySQL is fully started, it will initialize the database for the second time.

The first time you initialize the database, use --skip-networking (this option disables MySQL's TCP/IP connection method) to start MySQL for initialization.

After initialization is complete, restart MySQL with the --skip-networking option turned off.

The second time you initialize the database, you will set the root password.

How to determine whether MySQL has been fully started

Try to actively connect to MySQL. A successful connection indicates that the service has been fully started.

mysql -hlocalhost -P3306 -uroot

ACCIDENT

Since the above judgment method uses socket to connect to the database, but the first time only prohibits MySQL's TCP/IP connection method,

Therefore, the second database initialization may have been performed before the first database initialization was completed.

The second database initialization sets the root password earlier than the first database initialization, which causes the first initialization to fail because it cannot connect to the database.

Finally, the TCP/IP connection method was not enabled and the application could not connect to the database.

First modification

Use -h127.0.0.1 to connect to the database

mysql -h127.0.01 -P3306 -uroot

However, since the host of the root user is set to localhost, 127.0.0.1 is not allowed to connect, and the first modification fails.

Second revision

wait-for-it.sh 127.0.0.1:3306 --timeout=300

mysql -hlocalhost -P3306 -uroot

wait-for-it.sh is used to detect whether 127.0.0.1:3306 is in the listening state. If it is, it means that the first database initialization is completed.

Then use localhost to try to connect to the database.

Original link: k8scat.com/posts/wait-…

Summarize

This is the end of this article about accidents caused by MySQL startup. For more information about accidents caused by MySQL startup, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the mysql service not starting
  • Summary of several common problems when MySQL cannot be started
  • Summary of solutions for the problem that MySQL 5 cannot be started after installation (cannot start service)
  • Quick solution to MySQL service startup failure under CentOS 7
  • Solution to MySQL startup error 1053
  • Windows cannot start MySQL service and reports error 1067 solution
  • How to solve the problem of MySQL not starting with error 1067
  • Common commands for mysql authorization, startup, and service startup

<<:  Sitemesh tutorial - page decoration technology principles and applications

>>:  HTML uses marquee to achieve text scrolling left and right

Recommend

Analysis of MySQL general query log and slow query log

The logs in MySQL include: error log, binary log,...

Detailed explanation and examples of database account password encryption

Detailed explanation and examples of database acc...

HTML page jump and parameter transfer issues

HTML page jump: window.open(url, "", &q...

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

A brief discussion on the pitfalls of react useEffect closure

Problem code Look at a closure problem code cause...

Detailed Explanation of JavaScript Framework Design Patterns

Table of contents mvc mvp mvvm The source of Vue ...

Tutorial on using hyperlink tags in XHTML

Hyperlink, also called "link". Hyperlin...

...

Vue implements adding watermark to uploaded pictures

This article shares the specific implementation c...

Analysis of the principle of Rabbitmq heartbea heartbeat detection mechanism

Preface When using RabbitMQ, if there is no traff...

Native JS to achieve cool paging effect

This article uses an example to share with you a ...

Vue realizes adding watermark to uploaded pictures (upgraded version)

The vue project implements an upgraded version of...