I found the following code on mysql forge site.
MySQL Proxy : An easy way to log all warnings and errors into a MySQL table.
http://forge.mysql.com/tools/tool.php?id=133
This may sound too basic, but from where do I start if I need this functionality.
Here you have more details about MySQL proxy scripting.
What you need to do with the script you linked is just run it on MySQL database and it will do all the magic for you. It's a complete server side solution so you don't have to worry about logging errors in your client application. MySQL will automatically run read_query function for every row returned and read_query_result for every set returned.
Related
When I tried to build my web application, I was stucked for almost a week only because I didnot know to configure url with unicode information. Even if I publish the executed sql by hibernate, when the sql arrives at mysql server, it is actually encoded/decoded to different thing because of the usage of chinese character.
So I wonder is it possible to publish the arrived sql at mysql server side in order to make sure about what is going on at every level.
In order to publish the arrived sql at the mysql server side you should enable query logging
this link is showing how to do that
How to enable MySQL Query Log?
and official documentation
http://dev.mysql.com/doc/refman/5.7/en/query-log.html
Have inherited a MySQL database that was completely trashed by the latest Windows 10 build update. The server lost all the user and schema information.
I restored the database back and recreated the users, set all the permissions etc. Obviously I would like to mitigate against this happening in the future but can see no obvious way from workbench to generate a script to create the users and set the permissions as you would from SQL management studio.
Is this possible?
Yes this is possible.
You can execute requests with a batch that is loaded by MySQL with a command from the shell to make what you want done.
I had not tested it myself but I think this link could be helpful.
I have a .sql file (initial sql scripts). I have recently deployed application in cloudfoundry, So I want to run these scripts to make application work, Scripts will update more than 5 db tables.
Is there any other way to run the mysql scripts from the grails application on start up Or Is there any provision to run the scripts in the cloudfoundry.
you have several options here.
The first one (which I recommend), is to use something like http://liquibase.org/ (there is a Grails plugin for it: http://grails.org/plugin/liquibase). This tool will make sure that any script you give it will run prior to the app starting, without running the same script twice, etc. This is great to keep track of your database changes.
This works independently of CloudFoundry and would help anyone installing your app having an up to date schema
The second option would be to tunnel to the CloudFoundry database and run the script to the db. Have a look at http://docs.cloudfoundry.com/tools/vmc/caldecott.html or even easier with STS : http://blog.cloudfoundry.com/2012/07/31/cloud-foundry-integration-for-eclipse-now-supports-tunneling-to-services/
Yup, what ebottard said! :-) Although, personally I would opt for using the tunnel feature on VMC, but that said, I am a Ruby guy!
Be weary of the fact that there are timeouts against queries in MySQL if are bootstrapping your database with large datasets!
I want a simple way to see what commands are being sent to MySQL. I have several MySQL projects that sometimes have a few messy layers of code. I want something like SQL Server Profiler without all of the bells and whistles. I just need to see the SQL traffic. Not analyze which queries are executed most often.
I found MySQL Proxy and can't get it to work in Windows. I downloaded their binaries, and tried their first example LUA script from the link. It loads fine, but when I try to connect to port 4040 using mysql, I get:
ERROR 1105 (HY000): #07000MySQL Proxy Lua script failed to load. Check the error log.
What error log? I didn't even give it the credentials to connect to my real SQL Server. What can I do to get this to work? I'm open to other options (hopefully not sniffing traffic, but maybe if someone can make it easy).
Enable query logging in my.ini. this will write all queries to a log file
add the line
log = [querylog_filename]
Then restart the mysql service
using a program such as tail for win http://tailforwin32.sourceforge.net/ will allow you to watch the queries as they run.
if you have a problematic query you can enable slow logging as well. which will log important details about queries that take a long time to run
DC
I have encountered this problem a couple of times, in the last few days. So, it happens occasionally. I have setup mysql on a remote machine, and there is a java program on another machine querying the database to read and write records every few seconds.
I am using phpMyAdmin to administer my database. And, at times, after running some SQL query, the mysql server stops responding. Even the pinging the host machine doesn't succeed. And, I have to ask someone with physical access to the machine to boot it up again.
I checked for log files but couldn't find them in the mysql directory. Is logging disabled by default? What is missing here? And, how can I go about troubleshooting this?
EDIT:
I was able to ping the server after some while. So, the server must have been temporarily busy. It's not a specific query but things like re-ordering the data of a table serially under the browse tab.
Use a mysqlclient to make a connection and keep it open.
I personally use the mysql from the commandline.
If the server becomes unresponsive execute
SHOW PROCESSLIST;
It will list all mysql processes and will show how long queries are waiting/executing.
Optionally use the KILL statement to terminate the query that locking the tables.
KILL $pid
I'd highly recommend using MySQL's own GUI tools for database management, for a vriety of reasons:
They have full support for InnoDB tables, including Foreign Key management
You can use database-level security to make sure only you get into your data (unlike phpMyAdmin, which at best can only be root access installed behind a .htaccess password)
It is official and supported. No extra binaries run on the server, so you run no risk of it crashing and taking the server down with it (unless your query itself is locking it...)