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 deal with MySQL database related exceptions

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

Share

Shulou(Shulou.com)05/31 Report--

How to deal with MySQL database-related exceptions, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

As we all know, exceptions are inevitable in the use of any database. The following editor to explain the MySQL database-related exceptions how to deal with?

Problem 1: StartingMySQL..Managerofpid-filequitwithoutupdatingf [failed] StartingMySQL...Managerofpid-filequitwithoutupdating [failed] when starting mysql

Solution:

The first kind:

1. Delete the numeric suffix of all temporary files in the / usr/local/mysql/data/mysql-bin.* folder.

two。 Restart mysql (restart after binary installation) servicemysqldstart.

The second kind:

Edit / etc/my.cnf add:

[mysqld] datadir=/var/lib/mysql

The MySQL server stores the database in the directory defined by the datadir variable.

Kill after checking the existing process:

Ps-aux | grepmysql8016pts/200:00:00mysqld_safe8037pts/200:00:00mysqld

Restart mysql.

The third kind:

Comment out in / etc/my.cnf

Skip-federated= > # skip-federated

The fourth kind:

Sometimes this error occurs when datadir=/var/lib/mysql is set in / etc/my.cnf to restart mysql.

If not set separately, the mysql default data directory is under the mysql installation directory.

Problem 2: FATALERROR:Couldnotfind./bin/my_print_defaults appears when the system is allowed to generate its own library.

Solution: / usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data

Question 3: mysql_connect () [function.mysql-connect]: Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock' (13) / eccore/model/mysql.php94 or StartingMySQL/etc/init.d/mysql:line327:--socket=/var/lib/mysql/mysql.sock.

Solution:

1 > add the following code to let mysql apply this file to the tmp folder, which defaults to / var/lib/mysql/mysql.sock.

Modify / etc/my.cnf

[mysql] socket=/tmp/mysql.sock

2 > go to / tmp folder to create mysql.sock

Touchmysql.sock

3 > restart mysql

/ etc/init.d/mysqldrestart

How to deal with related exceptions in MySQL database

Question 4: the following error occurred when host A mysql accesses host B mysql:mysql-uroot-proot-P3306-h292.168.100.52: ERROR2003 (HY000): Can'tconnecttoMySQLserveron'192.168.100.52'

Solution:

1. The server should be accessible on the network (public network). If there is a firewall, open port 3306 (the default listening port for MySQL).

Turn off all firewalls / etc/rc.d/init.d/iptablesstop

Join the rule vim/etc/sysconfig/iptables

two。 The easiest way to set up a remote user on the mysql server is

GrantALLPRIVILEGESon*.*tousername@ "" identifiedby "root"

Question 5: there are several situations in which MySQLserverhasgoneaway occurs.

Solution:

1. Applications (such as PHP) execute batch MYSQL statements for a long time.

Solution:

Add or modify the following two variables in the my.cnf file:

Wait_timeout=2880000interactive_timeout=2880000

For a specific description of the two variables, you can google or refer to the official manual.

If you cannot modify my.cnf, you can set CLIENT_INTERACTIVE when connecting to the database, such as:

Sql= "setinteractive_timeout=24*3600"; mysql_real_query (...)

2. Execute a SQL, but the SQL statement is too large or contains BLOB or longblob fields. For example, the processing of picture data.

Solution:

Add or modify the following variables in the my.cnf file:

Max_allowed_packet=10M (you can also set the size you want)

The max_allowed_packet parameter is used to control the maximum length of its communication buffer.

After reading the above, have you mastered how to deal with MySQL database-related exceptions? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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

Database

Wechat

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

12
Report