Is there a text based mysql UI? - mysql

I don't mean the standard mysql-client CLI, but rather something similar to what midnight commander is to filesystem management. The simple command history of the basic cli is not bad but really doesn't cut it when testing more complex query, and the layout of the data isn't that great. PHPMyAdmin is useful and all, but it's ugly and requires a lot of mouse usage.
OS: linux

dbext.vim provides DB access from within Vi. It provides things like stored connections, schema browsing, command history, some auto completion, and bind variables.
I assume there is something similar for Emacs.

I know this is an old question, but just in case neither of the above solutions have worked for you I would like to recommend Mitzasql - a simple text based Mysql client which gives you a quick read-only access to the database, data manipulation can be done through regular sql queries.
disclaimer - I am the author of said tool.

In emacs, there is a build in mode M-x sql-mysql.
You will be prompted for a user name, password, schema name (or database name), and the server name.
From then on, when one opens a .sql file, emacs should bind that .sql file to the SQL buffer associated with the MySQL session.
Inside that mode you can get help with a "Control-H m" keystroke.
There is a family of emacs sql- modes. They all pretty much work the same.

Related

Phpmyadmin vs Jetbrains Datagrip for database management

I have been working with Phpmyadmin for quite some time and recently i came across Jetbrains Phpstorm and Intellij which i both really liked.
Now i found the database environment Datagrip.
I wanted to know objectively:
what are the advantages of Datagrip over Phpmyadmin and vice versa.
What does Datagripgive me that Phpmyadmin lacks?
What does Phpmyadmin give me that Datagrip lacks?
I am using PhpStorm and Datagrip since February 2017. Before that I was using Dreamweaver and PhpMyAdmin.
The only thing PhpMyAdmin had an advantage over Datagrip from my perspective, was searching the whole database. But since 2019 Datagrip has a "full text search" which does exactly the same.
Furthermore:
Datagrip is fully integrated into your IDE (PhpStorm, PyCharme, IntelliJ, etc). You don't need to leave it to run any SQL queries.
within the SQL console you have access to the "live templates" which let you insert huge code snippets impossible to remember via typing a few letters of the live template name. Before:
after:
SQL consoles are saved automatically (by a consecutive number). And you can save them as SQL files to any directory right from the console via ctrl/cmd + s
you also have access to the IDE's huge clipboard with (in my case) 100 previously copied text pieces, while each of them can be a whole (SQL) document:
it so easy to modify a table without writing any queries (table name, column name, foreign keys, indexes, column data type, etc):
the tables and search results are super easy to edit and update as if you would edit an Excel table
you can assign to /setup on any project as many databases as you like and access them easily
you can assign/setup and access any remote database via an SSH tunnel
you can assign/setup any type of DBMS:
Datagrip checks the SQL query syntax live, before you even run it
this is my IDE setup for testing query time on two identical sites running on different server setups (the one on nginx/mysql and the other one on Openlitespeed/Mariadb):
All that you get only for a couple of bucks! I pay now for PhpStorm only 80€ annually! I pay often much more for a single site license of some shitty wordpress plugin! But get a really really high quality software product with PhpStorm. Seriously, probably the only company I would LOVE to work as employee (being freelancer throughout my whole dev "career") is probably JetBrains. It seems as they can read my thoughts :D. Sure there are some few minor issues. But any time they bring out a new version I am excited as a child.
No I'm not paid by JetBrains :D And no I don't hype them because I'm Russian. At the time I felt in love with them I thought it is a Czech company with a bunch of Russian devs (nothing unusual in Europe). And Czech's in general don't like Russians. So I loved them even I thought they wouldn't love me :D Only a year after I've switched from Dreamweaver to PhpStorm I've found out it is a fully Russian company.
The only thing I hate in Datagrip is that the SQL console output shares for any reason a tab/window with Docker (dafuq?) and it is a huge pain in the as* to navigate between multiple query outputs/results (as in the example above where I compare the performance of two servers)
Update:
the only flaw of Datagrip from my perspective (pain in the as* to switch between console outputs) has gone now as well! :D
I've found a setting by which you can just simply open a "services" tree (Command + Shift + T) which list all the active/latest "services". I still don't understand why the Datagrip console output doesn't have a dedicated window, but at least I can now navigate easily between the different console's output:
What does Datagripgive me that Phpmyadmin lacks?
DataGrip provides fast code completion, based on the syntax — it can even complete your JOIN clause based on foreign keys.
It also has data editor — so you can edit several cells at once or you can edit many rows locally and then submit them.
Also you can navigate inside the grid y foreign keys.
Multi-cursor in the editor can help you edit a bunch of statements.
What does Phpmyadmin give me that Datagrip lacks?
PhpMyAdmin can export to PDF, ISO/IEC 26300 - OpenDocument Text and Spreadsheet, Word, LATEX
PhpMyAdmin has more administration features, dataGrip is not focused at administration at all
It also supports working with user accounts and privileges

MYSQL Database offline use

Is there a way to use a MYSQL database without the database management system.. Like use tables offline without installing the db management system on the machine..
If there is can you please point me in the right direction?
Thank you!
As far as I know, there is no way to do this.
However, there is a portable DBMS SQLIte. It comes in different ways and can be used on other platform with different programming languages.
After reading your comment, I'm almost sure, this is what you need.
It's not that fast as MySQL I guess, but it works.
You can use The embedded MySQL Server Library to access MySQL data files without running the MySQL server.
You can setup a database to work on your localhost. This will be offline unless you setup the front-end stuff to let the internet interact with it.
What exactly do you mean "without the database management system"? You always need a way of interacting with it, even if it is offline. (Otherwise how can it work for you?)
The server side piece of the application, mysql-server, is needed at a minumum to run mysql. This server application comes with all the tools built-in to manage the instance. I doubt you can prevent installation of this.
If you've actually opened the table files in a hex or text editor, you'll see that you will definitely need the mysql application installed to make any sense of them to use them. Sure the records are all there in plain text (.myd files for myisam, the ibdata1 file for innodb tables), but it would be a complete time-waster devising a custom app to parse or update the file structure, as well as trying to tie in table structure contained in the related files for each table.

MySQL database manipulation program for Windows? Like MS Access or MS SQL?

Is there any program (preferably official) for Windows that can be used to manipulate MySQL data dumps?
For example, easily importing a MySQL text dump and create the database for all kinds of manipulations (you know, common data operations such as select, update, insert, delete, export into CSV, etc.) via a GUI interface. Much like what you can do with MS Excel and MS Access.
I know only phpMyAdmin which requires a local web server environment which might a little too much for what I need.
I thought http://dev.mysql.com/downloads/mysql/ was what I needed and installed to find out that it's not.
Any such tools exist? I ask this is actually because these MySQL dumps are for my users who know nothing about SQL or anything technical. This is for them, not me. After they downloaded the SQL I provided, they ask me: "How can I open it?"
I tried to provide them CSV, but CSV generated by this approach: http://www.kavoir.com/2010/11/mysql-export-table-to-csv-text-files-for-excel.html would contain stuff like \" if the original data contains ". When you open the CSV in Excel, \" are all over the place.
http://www.webyog.com/en/
I used to use SQLyog at my last job. It's a pretty decent GUI tool for interacting with MySQL, either local or remote. It'll cost you $99 at the cheapest, but you can try it for 30 days. If you like it and it makes life easier, it could be worth the $99, as well.
Running a local server is actually pretty easy. I use xampp which was really easy to install and came set up and ready to use phpMyAdmin. It's also really easy to shut the whole server (or just parts of it) down when it's not in use to conserve system resources.

How to collaborate on mysql schema?

I'm working with another dev and together we're building out a MySQL database. We've each got our own local instances of MySQL 5.1 on our dev machines. We've not yet been able to identify a way for us to be able to make a local schema change (eg: add a field and some values for that field) and then export some kind of script or diff file that the other can import in. I've looked into Toad and Navicat's synchronization features but they seem oriented towards synchronizing between two instances, not an instance and an intermediate file. We thought MySQL Workbench would be great but this but the synchronization feature just seems plain broken. Any other ideas? How do you collaborate with others on the schema?
First of all put your final SQL schema into version control. So you'll always have a version of it with all changes. It can be a plain SQL file. Every developer in the team can use it as starting point to created his copy database. All changes must be applied to it. This will help you to find conflicts faster.
Also I used such file to create a test database to run unit-tests after each submit. So we were always sure that production code is working.
Then you can use any migration tool to move changed between developers. Here is similar question about this:
Mechanisms for tracking DB schema changes
If you're using PHP then look at Doctrine migrations.

How to synchronize development and production database

Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column.
Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up).
I work with mySQL and postreSQL databases.
What is your practise and what applications helps you in that.
You asked for a tool or application answer, but what you really need is a a process answer. The underlying theme here is that you should be versioning your database DDL (and DML, when needed) and providing change scripts to be able to update any version of your database to a higher version.
This set of links provided by Jeff Atwood and written by K. Scott Allen explain in detail what this ought to look like - and they do it better than I can possibly write up here: http://www.codinghorror.com/blog/2008/02/get-your-database-under-version-control.html
For PostgreSQL you could use Another PostgreSQL Diff Tool . It can diff two SQL Dumps very fast (a few seconds on a db with about 300 tables, 50 views and 500 stored procedures). So you can find your changes easily and get a sql diff which you can execute.
From the APGDiff Page:
Another PostgreSQL Diff Tool is simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema.
Have scripts (under source control of course) that you only ever add to the bottom off. That combined with regular restores from your production database to dev you should be golden. If you are strict about it, this works very well.
Otherwise I know lots of people use redgate stuff for SQLServer.
Another vote for RedGate SQL Compare
http://www.red-gate.com/products/SQL_Compare/index.htm
Wouldn't want to live without it!
Edit: Sorry, it seems this is only for SQL Server. Still - if any SQL Server users have the same question I'd definitely recommend this tool.
If you write your SQL statements for your development database (which are, I imagine, series of DDL instructions such as CREATE, ALTER and DROP), why don't you keep track of them by recording them in a table, with a "version" index? You will then be able to:
track your version changes
make a small routine allowing the "automatic" update of your production database by sending the recorded instructions to the database.
I really like the EMS tools.
There tools are available for all popular DB's and you have the same user experience for every type of DB.
One of the tools is the DB Comparer.
TOAD
saved many an ass several times in the past. Why do people run sql with no exit strategy?
the redgate one is good also.
Siebel (CRM, Sales, etc. management product) has a built-in tool to align the production database with the development one (dev2prod).
Otherwise, you've got to stick with manually executed scripts.
Navicat has a structure synchronisation wizard that handles this.
I solve this by using Hibernate. It can detect and autocreate missing tables, columns, etc.
You could add some automation to your current way of doing things by using dbDeploy or a similar script. This will allow you to keep track of your schema changes and to upgrade/rollback your schema as you see fit.
Here's a straight linux bash script I wrote for syncing Magento databases... but you can easily modify it for other uses :)
http://markshust.com/2011/09/08/syncing-magento-instance-production-development
DBV - "Database version control, made easy!" (PHP)