Is there a way to view past mysql queries with phpmyadmin? - mysql

I'm trying to track down a bug that's deleting rows in a mysql table.
For the life of me I can't track it down in my PHP code, so I'd like to work backwards by finding the actual mysql query that's removing the rows.
I logged in to phpmyadmin, but can't find a way to view the history of past sql operations.
Is there a way to view them in phpmyadmin?

Ok, so I actually stumbled across the answer.
phpMyAdmin does offer a brief history. If you click on the 'sql' icon just underneath the 'phpMyAdmin' logo, it'll open a new window. In the new window, just click on the 'history' tab.
That will give you the last twenty or so SQL operations.

There is a Console tab at the bottom of the SQL (query) screen. By default it is not expanded, but once clicked on it should expose tabs for Options, History and Clear. Click on history.
The Query history length is set from within Page Related Settings which found by clicking on the gear wheel at the top right of screen.
This is correct for PHP version 4.5.1-1

You just need to click on console at the bottom of the screen in phpMyAdmin and you will get the Executed history:

To view the past queries simply run this query in phpMyAdmin.
SELECT * FROM `mysql`.`general_log`
if it is not enabled, run the following two queries before running it.
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';

I don't think phpMyAdmin lets you do that, but I'd like to hear I'm wrong.
On the other hand you can enable query logging in MySQL: The General Query Log

Yes, you can log queries to a special phpMyAdmin DB table.
See SQL_history.

I am using phpMyAdmin Server version: 5.1.41.
It offers possibility for view sql history through phpmyadmin.pma_history table.
You can search your query in this table.
pma_history table has below structure:

You have to click on query window just below the phpMyAdmin logo, a new window will open.
Just click on SQL History tab. There you can see history of SQL Queries.

OK so I know I'm a little late and some of the above answers are great stuff.
As little extra though, while in any PHPMyAdmin page:
Click SQL tab
Click 'Get auto saved query'
this will then show your last entered query.

I may be wrong, but I believe I've seen a list of previous SQL queries in the session file for phpmyadmin sessions

Here is a trick that some may find useful:
For Select queries (only), you can create Views, especially where you find yourself running the same select queries over and over e.g. in production support scenarios.
The main advantages of creating Views are:
they are resident within the database and therefore permanent
they can be shared across sessions and users
they provide all the usual benefits of working with tables
they can be queried further, just like tables e.g. to filter down the results further
as they are stored as queries under the hood, they do not add any overheads.
You can create a view easily by simply clicking the "Create view" link at the bottom of the results table display.

you can run your past mysql with run /PATH_PAST_MYSQL/bin/mysqld.exe
it run your last mysql and you can see it in phpmyadmin and other section of your system.
notice: stop your current mysql version.
S F My English.

why dont you use export, then click 'Custom - display all possible options' radio button, then choose your database, then go to Output and choose 'View output as text' just scroll down and Go. Voila!

There is a tool called Adminer which is capable of doing all phpmyadmin job packed in single tiny php file.
http://www.techinfobit.com/how-to-import-export-database-without-any-extra-installation/

Related

Mysql Workbench - The best way to organize running frequently used SQL queries while development

I'm a java dev who uses Mysql Workbench as a database client and IntelliJ IDEA as an IDE. Every day I do SQL queries to the database from 5 up to 50 times a day.
Is there a convenient way to save and re-run frequently used queries in Mysql Workbench/IntelliJ IDEA so that I can:
avoid typing a full query which has already been used again
smoothly access a list of queries I've already used (e.g by auto-completion)
If there is no way to do it using Mysql Workbench / IDEA, could you please advise any good tools providing this functionality?
Thanks!
Create Stored Procedures, one per query (or sequence of queries). Give them short names (to avoid needing auto-completion).
For example, to find out how many rows in table foo (SELECT COUNT(*) FROM foo;).
One-time setup:
DELIMITER //
CREATE PROCEDURE foo_ct
BEGIN;
SELECT COUNT(*) FROM foo;
END //
DELIMITER ;
Usage:
CALL foo_ct();
You can pass arguments in in order to make minor variations. Passing in a table name is somewhat complex, but numbers of dates, etc, are practical and probably easy.
If you have installed SQLyog for your mysql then you can use Favorites menu option in which you can save your query and in one click it will automatically writes the saved query on Query Editor.
The previous answers are correct - depending on the version of the Query Browser they are either called Favorites or Snippets - the problem being you can't create sub-folders to group them. And keeping tabs open is an option - but sometimes the browser 'dies' - and you're back to ground 0. So the obvious solution I came up with - create a database table! I have a few 'metadata' fields for descriptions - the project a query is associated to; problem the query solves; and the actual query.
You could keep your query library in an SQL file and load that when WB opens (it's automatically opened when you restart WB and that file was open on last close). When you want to run a specific query place the caret in it's text and press Ctrl+Enter (Cmd+Enter on Mac) to run only this query. The organization of that SQL file is totally up to you. You have more freedom than any "favorites" solution can give you. You can even have more than one file with grouped statements.
Additionally, MySQL Workbench has a query history (see the Output Tab), which is saved to disk, so you can return to a query even month's after you wrote it.

How do I automatically clear output in MySQL workbench?

I'm trying to find the preference settings to have the output clear every time my statement or set of statements are executed. I would prefer this option instead of right clicking and clearing the output every time I want to. I just can't find it and I'm not sure it exists as an option.
There's no such thing like auto-clearing. If you want that implemented file a feature request in the MySQL bug system (http://bugs.mysql.com).

Database table columns missing in MySqlWorkBench

I am working with mysql workbench 5.2.47 on Mac. I have created new database, table and some columns in the table. Sometimes, when I open this database (connection is fine) in mysql workbench, it is not showing any columns that I created under the table. But, if i close and open mysql workbench multiple times, and then its displaying the columns under that table. It is not happening always, but sometimes only it is not showing any columns that I created under the table.
I couldn't any find solution or workaround what to do this to get the actual columns displayed under the table.
Screenshot for reference:
Solved! Seems like a lot of people are stuck in this odd situation.
There is an easy solution to this.
Hover abbove the "Object Info" and "Session" and your cursor will change to split arrows. Then all you have to do is drag it downward and it will reveal the hidden sidebar with Management, Schemas etc.
Enjoy!
I, personally, faced this problem only when I was disconnected from the server. So, when you try to execute an SQL query you receive an error like:
"Error Code: 2006. MySQL server has gone away."
Go to the option "Query" and then "Reconnect to Server," or simply close the connection and open it again. If yours happens to be the same case as that of mine, you should be able to get the columns displayed again.
Click the little "Refresh" icon (to the right of Schemas). Also, upgrade to Workbench 6.1.x as the 5.2 branch is no longer maintained.

MySQL Workbench to generate Catalog diff

I have problem using generate catalog diff in database tab, in MySQL Workbench, I am using ver5.2.33, the option generate catalog option has been disabled, while other option like, forward eng, reverse eng, synchronize model, works fine. Still I used the existing model only.
Option generate catalog diff is always been disabled.
I am using version 5.2.35 CE which should be similar to yours
Make sure all tabs are closed. ( For simplicity and lack of confusion )
Now that you are on "home" which should be an icon of a house on the tab, Go ahead and select new EER Diagram
On this page, you are going to click on menu Database and then select "Create diff Catalog"
Here you will choose option live for both connections
The next screen you will select your live database
Then on the next screen you will select the database you wish to compare.
The next screen you will select your live database you wish to compare to
Then on the next screen you will select the database you wish to compare.
The next screen will show you all your differences, it may take a little while for them to appear. For me, it took about 30 seconds with a 25MB database
If you already know those steps and cannot seem to reach them, then I highly suggest reinstalling your MySQL Workbench software.

disable per-column ordering in MYSQL workbench?

When I use MySQL workbench and get a huge dataset, i find it annoying that if I accidentally click on a row, workbench tries to order the data by that row - generally taking several minutes to complete.
I'm of the opinion that if I wanted a dataset ordered a particular way, I would have used an order-by clause.
Is there any way to disable the behavior of ordering a dataset by clicking on a particular column?
Unfortunately I think you're out of luck in this regard, unless of course you download the source code for MySQL Workbench and change the way the UI behaves and add in an option to disable column ordering on click.
Source is available here. (Change the 'select platform' drop down to 'Source Code')