Tag Archives: mysql

ERROR: mysqld failed while attempting to check config [How to Solve]

Problem Description:

the reason for the pit I encountered in learning docker is that the MySQL image used in the video is 5.7, and I use more than 8.0 (8.0.16) </ font>

Error code


Cause analysis:

Start from the third step, analyze step by step, and directly look at the solutions

1. Pull image

I pulled more than 8.0, so I encountered this pit

docker pull mysql:8.0.16

2. View mirror

docker images

3. Run container

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16

After running, you can see the container ID, but it is empty when viewed with docker PS

4. View container

docker ps

5. View all containers

docker ps -a

6. View log analysis

docker logs 容器id

7. Cause

The configuration location of MySQL is wrong when running the container. The configuration location of MySQL 5.7 is/etc/MySQL. The configuration location above MySQL 8.0 is/etc/MySQL/conf.d. just modify the configuration location according to the MySQL version


Solution:

1. Delete container

docker rm Container id or NAME

2. Modify the configuration of the run container

The conf configuration is modified as shown in the figure below

/mydata/mysql/conf:/etc/mysql
					||
					||
					||
					\/
/mydata/mysql/conf:/etc/mysql/conf.d

3. Rerun

Summary:

Mysql8.0 and above configuration

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16

Mysql5.7 configuration

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:5.7

Solutions to errors in the final running of JDBC programming

An error is reported at the end of JDBC programming:

Exception in thread “main“ java.sql.SQLException: Unknown initial character set index ‘255‘ received

  resolvent:

When establishing a connection between JDBC and the database, add the following after the URL:

?useUnicode=true&characterEncoding=utf-8

As shown in the figure:

Add reason:

        Mysql database uses GBK coding, while the project database uses UTF-8 coding.

An error occurs when pymysql uses% d to pass in parameters

Error:

When using pymysql, an error occurs when using% d to pass parameters in the SQL statement. As shown in the figure:

Error information: typeerror:% d format: a number is required, not str

Cause of problem:

         When a parameter of type int is passed in, it is converted to a parameter of type str. Therefore, the solution is to change% d into% s, pass in int type, and it can still be executed.

Modified:

Data of type int passed in:

Can execute successfully

Solution:

          When data of type int is passed in, the parameter is still passed with% s.

[Solved] MySQL connection error: communications link failure

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

1. Causes

Communication link failure occurs when Java connects to the database. Why can’t you log in

2 solution (my situation is invalid)

Method 1

[1] Login mysql,cmd command
mysql -h host address -u username -p user password (for example mysql -hlocalhost -uroot -p123456)

[2] Check the wait_timeout,cmd command.
show global variables like 'wait_timeout';


[3] If the wait_timeout is too small, modify it. cmd command:
set global wait_timeout=604800;
set global interactive_timeout=604800;

Method 2

Add the following parameter to the connection URL: &autoReconnect=true

3. Troubleshooting of other causes

If the above two methods are not solved, check whether there are problems in the server environment and database port.

After investigation, if the database port passes through nginx reverse proxy, or if the database port performs proxy operations through other servers, it is caused by nginx reverse proxy timeout that the database cannot be connected

You need to modify the configuration file of nginx and use steam agent Mysl

stream {
     upstream mysql {
         zone myapp1 64k;
         server localhost:3306 weight=1 max_fails=3 fail_timeout=30s;
     }
     server {
         listen 10086;
         proxy_connect_timeout 1s;
         proxy_timeout 3s;
         proxy_pass mysql;
    }
}

In other cases, you can also check whether the MySQL port has been proxy

[Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported

Today, I installed a MySQL database in the server because there was a ‘)’ in the initial password assigned. I always reported an error when entering the password. I tried many changes on the Internet. It’s useless to wrap anything in quotation marks. Next, let’s talk about my solution:

Step 1:

vi /etc/my.cnf

After opening, add a sentence: skip grant tables

The function is equivalent to that no password is required for login

Step 2:

Restart MySQL

systemctl restart mysqld

Step 3:

Direct Logins

mysql -uroot -p

Step 4:

// goto database
use mysql
// refresh the data
flush privileges;

Step 5:

Change password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';

Then, delete the just secret free statement and restart MySQL

Login

mysql -uroot -p[NEW PASSWORD]

The MAC system installs MySQL client, and the error is solved_ config not found

The MAC system installs MySQL client, and the error is solved_ config not found

Using PIP3 install MySQL_ Client error

The error message is as follows: prompt: oserror: MySQL_ config not found
python setup.py egg_ info Check the logs for full command output
mysql_ Config not found

Solve the problem according to the error report

Prompt that the file does not exist. Use find to find the file and verify whether the file exists
find/- name MySQL_ Config
you can see that the file exists. It is preliminarily judged that the environment variable is not configured

resolvent

Add the queried address to the environment variable
export path = $path:/usr/local/mysql-5.6.38-macos10.12-x86_ 64/bin

Verify again

Download again, the prompt is successful, and the problem is solved

Problem regression

Because MySQL has been downloaded before, the environment variable configuration may be deleted when operating other contents. This method is not applicable to all cases

An error is reported when kettle connects Oracle database and MySQL database

1. An error is reported when kettle connects to Oracle database

When kettle connects to Oracle database for the first time, it reports an error “wrong connection to database [Oracle]  ”, This is because spoon lacks the jar package corresponding to Oracle. If Oracle or Oracle client is installed, you can copy the corresponding jar file from their installation directory to solve the error problem.

Solution:

Copy and paste all files starting with ojdbc in Oracle database, such as ojdbc5 and ojdbc6.jar, into the spoon directory, such as D: \ kettle \ data-integration-8.2.0.7-719 \ lib\   Just under the path.

2. An error is reported when kettle connects to MySQL database

The error contents are as follows:

  This is caused by the missing jar connection package of MySQL.

Solution:

You need the jar connection package of MySQL database, such as mysql-connector-java-8.0.11.jar, copy and paste it into the spoon directory, such as D: \ kettle \ data-integration-8.2.0.7-719 \ lib\   Just under the path.

The attachment download link is as follows:

Kettle driver. TXT other document resources CSDN Download

How to Solve canal & MYSQL or “Kafka cannot consume data” Error

Error 1: interaction between canal and MySQL

Explanation: the essential reason is that the same IP generates too many interrupted database connections (exceeding the maximum value of max_connect_errors) in a short time

If the MySQL server continuously receives requests from the same host, and all these continuous requests are unsuccessful, the established connection will be interrupted. When the cumulative value of these continuous requests is greater than When you set the value of max_connect_errors, the MySQL server will block all subsequent requests from this host.

Solution:   Mysqladmin flush hosts – H 127.0.0.1 – uroot – P password

Error 2: Kafka cannot consume data

Reason: the number of partitions of the theme I created is insufficient. You can manually add the same number of partitions as those set in instance.properties in conf/example of canal

Execute the following command:

//1. View the subject details and the number of partitions

kafka-topics.sh –bootstrap-server hadoop102:9092 –describe –topic ODS_BASE_DB_C

//2. Manually add the number of partitions

kafka-topics.sh –bootstrap-server hadoop102:9092 –alter –partitions 4 –topic ODS_BASE_DB_C

How to Solve All masterha_check_repl Error

 

1. Troubleshooting ideas

[root@DBMysql ~]#masterha_check_repl --conf=/etc/masterha/app1.cnf

There are two main reasons for the following error reports:

① MySQL is installed with the source code, resulting in the inconsistency between the MySQL directory and the MHA default directory. The solution is to use ln – s as the relevant soft connection. Note: my MySQL database is installed by MySQL user and MHA is installed by root user. If I install it under the same user, I wonder whether such problems can be avoided

② The user permissions corresponding to the candidate_master are insufficient.

2. error 1

[root@data01 ~]# masterha_check_repl--conf=/etc/masterha/app1.cnf
Tue Apr 7 22:31:06 2015 - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
Tue Apr 7 22:31:07 2015 - [info] Reading application default configuration from/etc/masterha/app1.cnf..
Tue Apr 7 22:31:07 2015 - [info] Reading server configuration from/etc/masterha/app1.cnf..
Tue Apr 7 22:31:07 2015 - [info] MHA::MasterMonitor version 0.56.
Tue Apr 7 22:31:07 2015 - [error][/usr/local/share/perl5/MHA/Server.pm,ln303] Getting relay log directory orcurrent relay logfile from replication table failed on192.168.52.130(192.168.52.130:3306)!
Tue Apr 7 22:31:07 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/share/perl5/MHA/ServerManager.pmline 315
Tue Apr 7 22:31:07 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
Tue Apr 7 22:31:07 2015 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

Solution:

On 192.168.52.130, vim /etc/my.cnf and add
relay-log=/home/data/mysql/binlog/mysql-relay-bin
Then restart mysql, and then go to reset the slave connection.
STOP SLAVE;
RESET SLAVE;
CHANGE MASTER TOMASTER_HOST='192.168.52.129',MASTER_USER='repl',MASTER_PASSWORD='repl_1234',MASTER_LOG_FILE='mysql-bin.000178',MASTER_LOG_POS=459;
START SLAVE;

2. error 2

[root@data01 perl]# masterha_check_repl--conf=/etc/masterha/app1.cnf
Thu Apr 9 00:54:32 2015 - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
Thu Apr 9 00:54:32 2015 - [info] Reading application default configuration from/etc/masterha/app1.cnf..
Thu Apr 9 00:54:32 2015 - [info] Reading server configuration from/etc/masterha/app1.cnf..
Thu Apr 9 00:54:32 2015 - [info] MHA::MasterMonitor version 0.56.
Thu Apr 9 00:54:32 2015 - [error][/usr/local/share/perl5/MHA/Server.pm,ln306] Getting relay log directory orcurrent relay logfile from replication table failed on 192.168.52.130(192.168.52.130:3306)!
Thu Apr 9 00:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at/usr/local/share/perl5/MHA/ServerManager.pm line 315
Thu Apr 9 00:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
Thu Apr 9 00:54:32 2015 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

Solution:

/etc/masterha/app1.cnf file inside the parameter configuration, user and repl_user are mysql account, need to create a good, here is only created repl_user but not create a good user account: user=manager
user=manager
password=manager_1234
repl_user=repl
repl_password=repl_1234

On the mysql node, create the "manager manager" account that allows manager access to the database, mainly for SHOW SLAVESTATUS,RESET SLAVE; so you need to execute the following command.
GRANT SUPER,RELOAD,REPLICATIONCLIENT,SELECT ON *.* TO manager@'192.168.52.%' IDENTIFIED BY 'manager_1234';

3. error 3

[root@oraclem1 ~]# masterha_check_repl--conf=/etc/masterha/app1.cnf
Thu Apr 9 23:09:05 2015 - [warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
Thu Apr 9 23:09:05 2015 - [info] Reading application default configuration from/etc/masterha/app1.cnf..
Thu Apr 9 23:09:05 2015 - [info] Reading server configuration from/etc/masterha/app1.cnf..
Thu Apr 9 23:09:05 2015 - [info] MHA::MasterMonitor version 0.56.
Thu Apr 9 23:09:05 2015 - [error][/usr/local/share/perl5/MHA/ServerManager.pm,ln781] Multi-master configuration is detected, but two or more masters areeither writable (read-only is not set) or dead! Check configurations fordetails. Master configurations are as below:
Master 192.168.52.130(192.168.52.130:3306),replicating from 192.168.52.129(192.168.52.129:3306)
Master 192.168.52.129(192.168.52.129:3306),replicating from 192.168.52.130(192.168.52.130:3306)
Thu Apr 9 23:09:05 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at/usr/local/share/perl5/MHA/MasterMonitor.pm line 326
Thu Apr 9 23:09:05 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
Thu Apr 9 23:09:05 2015 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

Solution:

mysql> set global read_only=1;
Query OK, 0 rows affected (0.00 sec)

4. error 4

Thu Apr 9 23:54:32 2015 - [info] Checking SSH publickey authentication andchecking recovery script configurations on all alive slave servers..
Thu Apr 9 23:54:32 2015 - [info] Executing command : apply_diff_relay_logs --command=test--slave_user='manager' --slave_host=192.168.52.130 --slave_ip=192.168.52.130--slave_port=3306 --workdir=/var/tmp --target_version=5.6.12-log--manager_version=0.56 --relay_dir=/home/data/mysql/data--current_relay_log=mysqld-relay-bin.000011 --slave_pass=xxx
Thu Apr 9 23:54:32 2015 - [info] Connecting to [email protected](192.168.52.130:22)..
Can't exec "mysqlbinlog": No suchfile or directory at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.
mysqlbinlog version command failed with rc1:0, please verify PATH, LD_LIBRARY_PATH, and client options
at/usr/local/bin/apply_diff_relay_logs line 493
Thu Apr 9 23:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln205] Slaves settings check failed!
Thu Apr 9 23:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln413] Slave configuration failed.
Thu Apr 9 23:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/bin/masterha_check_repl line 48
Thu Apr 9 23:54:32 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
Thu Apr 9 23:54:32 2015 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!

Solution:

All nodes are executed once
[root@data02 ~]# type mysqlbinlog
mysqlbinlog is/usr/local/mysql/bin/mysqlbinlog
[root@data02 ~]# ln -s/usr/local/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog

5. error 5

Thu Apr 9 23:57:24 2015 - [info] Connecting to [email protected](192.168.52.130:22)..
Checking slave recovery environment settings..
Relay log found at /home/data/mysql/data, up to mysqld-relay-bin.000013
Temporary relay log file is /home/data/mysql/data/mysqld-relay-bin.000013
Testing mysql connection and privileges..sh: mysql: command not found
mysql command failed with rc 127:0!
at/usr/local/bin/apply_diff_relay_logs line 375
main::check()called at /usr/local/bin/apply_diff_relay_logs line 497
eval{...} called at /usr/local/bin/apply_diff_relay_logs line 475
main::main()called at /usr/local/bin/apply_diff_relay_logs line 120
Thu Apr 9 23:57:24 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln205] Slaves settings check failed!
Thu Apr 9 23:57:24 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln413] Slave configuration failed.
Thu Apr 9 23:57:24 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/bin/masterha_check_repl line 48
Thu Apr 9 23:57:24 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
Thu Apr 9 23:57:24 2015 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

Solution:

#All nodes are executed once
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

6. error 6

#The user permissions of the switched machine do not match

Fri Apr 10 00:58:36 2015 - [info] Executing command : apply_diff_relay_logs--command=test --slave_user='manager' --slave_host=192.168.52.130--slave_ip=192.168.52.130 --slave_port=3306 --workdir=/var/tmp--target_version=5.6.12-log --manager_version=0.56--relay_dir=/home/data/mysql/data--current_relay_log=mysqld-relay-bin.000011 --slave_pass=xxx
Fri Apr 10 00:58:36 2015 - [info] Connecting to [email protected](192.168.52.130:22)..
Checking slave recovery environment settings..
Relay log found at /home/data/mysql/data, up to mysqld-relay-bin.000013
Temporary relay log file is/home/data/mysql/data/mysqld-relay-bin.000013
Testing mysql connection and privileges..Warning: Using a password onthe command line interface can be insecure.
ERROR 1142 (42000) at line 1: CREATEcommand denied to user 'manager'@'192.168.52.130' for table'apply_diff_relay_logs_test'
mysql command failed with rc 1:0!
at/usr/local/bin/apply_diff_relay_logs line 375
main::check()called at /usr/local/bin/apply_diff_relay_logs line 497
eval{...} called at /usr/local/bin/apply_diff_relay_logs line 475
main::main()called at /usr/local/bin/apply_diff_relay_logs line 120
Fri Apr 10 00:58:37 2015 -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln205] Slaves settingscheck failed!
Fri Apr 10 00:58:37 2015 -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln413] Slave configurationfailed.
Fri Apr 10 00:58:37 2015 -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened onchecking configurations. at/usr/local/bin/masterha_check_repl line 48
Fri Apr 10 00:58:37 2015 -[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln523] Error happened onmonitoring servers.
Fri Apr 10 00:58:37 2015 - [info] Got exitcode 1 (Not master dead).

MySQL Replication Health is NOT OK!

Solution:

#Execute the following authorization statement sql
GRANT CREATE,INSERT,UPDATE,DELETE,DROP ON*.* TO manager@'192.168.52.%';

[Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)

MYSQL Startup error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)

[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@iZ2zei01n7f2wrecqn5249Z ~]# lsof -i:3306
-bash: lsof: command not found
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# netstat -ntlp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      950/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      969/master          
tcp6       0      0 ::1:25                  :::*                    LISTEN      969/master          
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-11-01 19:27:48 CST; 14s ago
  Process: 1724 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 1664 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1723 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─1723 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─1890 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/...

Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Support MySQL by buying support/licenses at http://shop.mysql.com
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Note: new default config file not created.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Please make sure your config file is current
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: WARNING: Default config file /etc/my.cnf exists on the system
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: This file will be read by default by the MySQL server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: If you do not want to use this, either remove it, or use the
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: --defaults-file argument to mysqld_safe when starting the server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 01 19:27:48 iZ2zei01n7f2wrecqn5249Z systemd[1]: Started MySQL Community Server.

Start it.

service mysqld start

Recheck status

service mysqld status

Just as shown above
set the password

mysqladmin -u root password '123456'

Sign in

mysql -u root -p

General error: 2006 MySQL server has gone away [How to Solve]

Congratulations on your journey;

There are many reasons for this. Let’s not talk about the others. Let’s talk about the problems that occurred today; Eliminate the problem of the database itself (my MySQL does not go down at this time.) it is the problem of the program. This problem is that the process always exists, but it has not operated the database for too long, resulting in the disconnection of the database, but suddenly a piece of data comes. At this time, the process will not re link the database, but use the original link (disconnected at this time), so there is no way to find the database, so this error is reported.

Solution:

$round = mt_rand(1, 10);
if ($round == 6) {
    // Query a sql to avoid unavailability of the process due to connection timeout
    $dividend = Db::query("select id from think_member_group where  `id` = 1");
}

A random number. The core of this method is to let your process check the database every few seconds so that the link will not be disconnected.

MYSQL Use cmd to change root password error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha

MYSQL Use cmd to change root password error:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(“123456”) where user = “root”‘ at line 1

Prompt for SQL syntax error
Change the password with another command

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

Modified successfully