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

MySQL Series 4 SQL Syntax

Table of contents Tutorial Series 1. Introduction...

Implementing custom radio and check box functions with pure CSS

1. Achieve the effect 2 Knowledge Points 2.1 <...

js array entries() Get iteration method

Table of contents 1. Detailed syntax of entires()...

Detailed explanation of redundant and duplicate indexes in MySQL

MySQL allows you to create multiple indexes on th...

Sample code for nginx to achieve dynamic and static separation

1. Simple configuration of nginx's dynamic an...

Summary of several APIs or tips in HTML5 that cannot be missed

In previous blog posts, I have been focusing on so...

How to convert Chinese into UTF-8 in HTML

In HTML, the Chinese phrase “學好好學” can be express...

How to implement page screenshot function in JS

"Page screenshot" is a requirement ofte...

Troubleshooting ideas and solutions for high CPU usage in Linux systems

Preface As Linux operation and maintenance engine...

Summary of some problems encountered when integrating echarts with vue.js

Preface I'm currently working on the data ana...

Building FastDFS file system in Docker (multi-image tutorial)

Table of contents About FastDFS 1. Search for ima...

Collapsed table row element bug

Let's take an example: The code is very simple...