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

Implementation of CSS dynamic height transition animation effect

This question originated from a message on Nugget...

JavaScript pre-analysis, object details

Table of contents 1. Pre-analysis 1. Variable pre...

Let's talk about MySQL joint query in detail

Table of contents Union query 1. Query the ID and...

Linux system repair mode (single user mode)

Table of contents Preface 1. Common bug fixes in ...

Example analysis of mysql user rights management

This article describes the MySQL user rights mana...

Detailed explanation of mysql scheduled tasks (event events)

1. Brief introduction of the event An event is a ...

Tomcat's class loading mechanism process and source code analysis

Table of contents Preface 1. Tomcat class loader ...

How to build nfs service in ubuntu16.04

Introduction to NFS NFS (Network File System) is ...

MySQL master-slave replication principle and points to note

Written in front I have been writing a special to...

jQuery+swiper component realizes the timeline sliding year tab switching effect

Result: Implementation code: Need to be used with...

How to define input type=file style

Why beautify the file control? Just imagine that a...