MySQL Trace sql

Source: Internet
Author: User
Tags mysql client

SQL Trace executed in MySQL is much simpler than Oracle and has a log on its own. We just have to open the log record, execute the SQL statement, and look at the log.
1. First open the log switch
Use command: Show variables like '%log% ';
Can see a query result:

Set it to ON, using the following command:
Set Global General_log=on
Check again: Show variables like '%log% '; General_log's switch should have been opened.

Note that we can also see a general_log_file, which has a default value that we can modify or not change.
Let's change it, use VI/ETC/MYSQL/MY.CNF (I tried to set it up, but I didn't succeed, I could only modify the MySQL configuration file)
Add one line: Log=/tmp/my_luyx.log
Restart MySQL and check out show variables like '%log% ' again;
This is fully set up, run some SQL statements on the MySQL client, and in/tmp/my_luyx.log you can see the SQL statement that you just executed.

============mysql non-native connection reported 10061 error ==============
With the sudo apt-get install mysql-server-5.0 installed on Ubuntu, MySQL is not accessible outside, but access on Ubuntu is no problem.
Hint: can ' t connect to MySQL server on * * * (11061)
Then start looking for the reason:
1. MySQL is already open, the user has been created, and the user's access rights are @% 3306 port not open?
Use the Nestat command to view the 3306 port status:
~# Netstat-an | grep 3306

From the results, it can be seen that port 3306 is only listening on IP, so it denies access to other IPs. Workaround: Modify the/etc/mysql/my.cnf file. Open the file and find the following:
# Instead of skip-networking The default is now-listen only on
# localhost which are more compatible and are not less secure.
Bind-address =
Comment out the above line or replace the with the appropriate, or comment out.

After restarting, re-use netstat detection:
~# Netstat-an | grep 3306
You can then connect thetransferred from:

MySQL Trace sql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.