I know that there is general_log that logs all queries, but I want to find out which query has an error, and get the error message. I have tried running an error query on purpose, but it logs as a normal query and doesn't report it with error. Any ideas?
Linux – How to log error queries in thesql
configurationlinuxloggingMySQL
Related Solutions
Another command that might be available and also works quite well for this is 'blkid'. It's part of the e2fsprogs package. Examples of it's usage:
Look up data on /dev/sda1:
topher@crucible:~$ sudo blkid /dev/sda1
/dev/sda1: UUID="727cac18-044b-4504-87f1-a5aefa774bda" TYPE="ext3"
Show UUID data for all partitions:
topher@crucible:~$ sudo blkid
/dev/sda1: UUID="727cac18-044b-4504-87f1-a5aefa774bda" TYPE="ext3"
/dev/sdb: UUID="467c4aa9-963d-4467-8cd0-d58caaacaff4" TYPE="ext3"
Show UUID data for all partitions in easier to read format:
(Note: in newer releases, blkid -L
has a different meaning, and blkid -o list
should be used instead)
topher@crucible:~$ sudo blkid -L
device fs_type label mount point UUID
-------------------------------------------------------------------------------
/dev/sda1 ext3 / 727cac18-044b-4504-87f1-a5aefa774bda
/dev/sdc ext3 /home 467c4aa9-963d-4467-8cd0-d58caaacaff4
Show just the UUID for /dev/sda1 and nothing else:
topher@crucible:~$ sudo blkid -s UUID -o value /dev/sda1
727cac18-044b-4504-87f1-a5aefa774bda
Short answer: you can't. Ports below 1024 can be opened only by root. As per comment - well, you can, using CAP_NET_BIND_SERVICE, but that approach, applied to java bin will make any java program to be run with this setting, which is undesirable, if not a security risk.
The long answer: you can redirect connections on port 80 to some other port you can open as normal user.
Run as root:
# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
As loopback devices (like localhost) do not use the prerouting rules, if you need to use localhost, etc., add this rule as well (thanks @Francesco):
# iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
NOTE: The above solution is not well suited for multi-user systems, as any user can open port 8080 (or any other high port you decide to use), thus intercepting the traffic. (Credits to CesarB).
EDIT: as per comment question - to delete the above rule:
# iptables -t nat --line-numbers -n -L
This will output something like:
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 redir ports 8088
2 REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8080
The rule you are interested in is nr. 2, so to delete it:
# iptables -t nat -D PREROUTING 2
Best Answer
In short, There's no easy answer.
But if you have no other choice then to log errors on server rather then in client app, you [Luke] can use the source.
I give directions rather then patch, and it may apply differently to your mysqld version. In mysql source dir, in file sql/sql_parce.cc, in function
void mysql_parse(THD *thd, const char *inBuf, uint length, const char ** found_semicolon)
after statement
bool err= parse_sql(thd, & parser_state, NULL);
in
else
clause to followingif(!err)
statement, that looks likeinsert string like
DBUG_PRINT("info",("query was: %s",inBuf));
so it should look like
Then, run ./configure with flag --with-debug (among others that you use), build, and run mysqld command with flags as usual, but add debugging flag -#d,info:f,mysql_parse, well, just like this:
then, what you've got in output looks like this:
Also, you may find useful these links:
Hope that helps.