?
Solved

Force Error to be written to MySQL's error log

Posted on 2006-07-17
6
Medium Priority
?
472 Views
Last Modified: 2012-05-05
I'm currently running MySQL 4.1.12 and was wondering if it is possible to force an error message to be written to the MySQL error log.  I'm new to MySQL but have worked with SQL Server for over 10 years.  In SQL Server you were allowed to raise an error and depending on the severity level you passed it, it could be written to the SQL Server error log.  

I'm interested in doing this because we are having issues with the MySQL error log - nothing is being written to it.  I'm figuring if I can at least attempt a way of forcing a bogus error message to the error log, then I can do fruther testing to see if MySQL is actually writing to the MySQL error log.

Thanks for your help in advance!
Patty Hernon
0
Comment
Question by:pattyhernon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 6

Expert Comment

by:chigs20
ID: 17125523
Patty,
Have you enabled error logging in the my.cnf (linux) / my.ini (windows) file? (this is not done automatically during installation)

Linux it'll be output to default installation location = hostname.err

Windows: If you do not specify --log-error and if you use the --console option, errors are written to stderr, the standard error output. Usually this is your terminal.

Chigs
0
 

Author Comment

by:pattyhernon
ID: 17130131
Hi Chigs:

Thanks for the quick reply.  We are running on a linux server and error logging is configured in the my.cnf file (err-log=/var/log/mysqld.log).  

We do get some messages written to the error log if we stop and restart MySQL.  (See below for example.)  
>>> Sample of error log <<<
060715 09:05:17  mysqld ended
060715 09:10:36  mysqld started
060715  9:10:39  InnoDB: Started; log sequence number 713 591460636 /usr/libexec/mysqld: ready for connections.
Version: '4.1.12-log'  socket: '/export/DB/mysqldb/mysql.sock'  port: 3306  Source distribution
>>>>>>>>>>>>>>>>>>>>

Once MySQL is up and running, we do not get anymore error messages and at some point it stops.  I find it really hard to believe that MySQL can be running for 2 months without any kind of problems or warnings occurring?  So my thinking was if I could manually focus an error message to be written to the error log, it would help me in figuring out the problem I'm really trying to fix.

Any ideas if this type of function is possible?

Thanks,
Patty
0
 
LVL 6

Expert Comment

by:chigs20
ID: 17131360
Patty,
I tried creating db's and improper tables which forces errors (e.g. create table test (id int unsigned NOT NU);) but those do not get written to the log, which is odd.  If you have a development environment you can change the my.cnf file and set parameters ridiculously high:

sort_buffer_size = 10M
read_buffer_size = 10M
join_buffer_size = 10M
innodb_buffer_pool_size = 500M
etc...
Then connect to the server with many threads and eventually the server will crash because of the lack of RAM (depending on how much RAM you have):
Min_RAM_Needed = global params + (thread params * max_connections)

0
 

Author Comment

by:pattyhernon
ID: 17157200
Hi Chigs:

Again, Thanks for the quick reply and suggestions.

It turns out that a co-worker knows what's going on.  It's basically a problem with MySQL's error log that I'm trying to track down and figured that if I could figure out a way to force an error message to the error log, it would help me in troubleshooting the real problem.  

To make a long story short, it turns out the problem is with Linux (RedHat's) log rotation.  It's is not renaming \ re-opening the correct error log file.   (Here's the link for the bug: http://bugs.mysql.com/bug.php?id=6061).  

Thanks for all your suggestions.  It was much appreciated.

Take care!
Patty
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17586318
PAQed with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question