How do I start a program from VB.Net and pass it arguments? - mysql

Is possible? I plan to backup mysql database using vb.net. If you know any beginner tutorial on how to do this, then please let me know.

If I understand the question correctly, you want to start mysql.exe from VB.Net and supply some command-line parameters to tell it what to do (in your case, do a database backup). (FWIW, you might be better off using mysqldump.exe for that.)
You can start any process via the System.Diagnostics.Process.Start method. You'll probably want either this variant that gives you full control over the startup, or this one that just lets you specify the process (EXE) name and arguments. Here's a page with lots of examples. They're in C#, but it shows using these methods; the syntactic differences don't (I suspect) get in the way much.
Off-the-cuff example:
Imports System.Diagnostics
Process.Start("mysqldump.exe", "myDatabaseName")
' Or include the path:
Process.Start("C:\Program Files\MySQL\MySQL Server\bin\mysqldump.exe", "myDatabaseName")

Related

How does the phpMyAdmin export feature work?

If I were to want to create a PHP function that does the same thing as the Export tab in phpMyAdmin, how could I do it? I don't know if there is a MySQL function that does this or if phpMyAdmin just builds the export file (in SQL that is) manually. Without shell access. Just using PHP.
I tried the documentation for mysqldump, but that seemed to require using the shell. I'm not quite sure what that even is -- maybe my question is: how do you use shell?
My silly idea is to allow non-technical users to build a site on one server (say a localhost) using MySQL then export the site, database and all, to another server (eg. a remote server).
I think I'm pretty clear on the Import process.
You can check the phpMyAdmin source code (an advantage of open-source software). Check the export.php script and the supporting functions in the libraries/export/sql.php script file.
In summary, what phpMyAdmin does is:
get a list of the tables in the given database (SHOW TABLES FROM...),
get the create query for each table (SHOW CREATE TABLE...),
parse it and extract column definitions from it,
get all data (SELECT * FROM...)
build a query according to column data.
I've written similar code for my own apps (for backup purposes, when the GPL license of phpMyAdmin doesn't allow me to use it), however I use DESCRIBE to get column definitions. I think they rather parse the SHOW CREATE TABLE output because contains more information than DESCRIBE output.
This way to generate SQL sentences requires a bit of care to handle the escaping but it allows for some flexibility, as you can convert types, filter or sanitize data, etc. It is also a lot slower than using a tool like mysqldump and you should take care of not consuming all available memory (write soon, write often, don't keep everything in memory).
If you will implement a migration process (from server to server) maybe it would be easier to do it with some shell scripting and calling mysqldump directly, unless you will do everything with PHP.

How to get value from hbase and put it into a variable?

This is probably a noob question, so I apologize in advance.
The HBase console, as far as I understand, is an extension (or a script running over) JIRB. Also, it comes with several HBase-specific commands, one of which is 'get' - to retrieve columns\values from a table.
However, it seems like 'get' only writes to screen and doesn't output values at all.
Is there any native hbase console command which will allow me to retrieve a value (e.g. a set of rows\columns), put them into a variable and retrieve their values?
Thanks
No, there is not a native console command in 0.92. If you dig into the source code, there is a class Hbase::Table that could be used to do what you want. I believe this is going to be more exposed in 0.96. At this point, I have resorted to adding my own Ruby to my shell to handle a variety of common tasks (like using SingleColumnValueFilters on scans).

mysql udf read my.cnf

I'm trying to write a MySQL UDF (User Definied Function), which should read the configuration file of MySQL - my.cnf -, or access MySQL session and status vars.
How do I do that ?
I'm sure, there are functions implemented in MySQL source code - somewhere ... for this functionality.
How do I find them?
Also, is there a good MySQL source API documentation?
Thanks,
krisy
The easiest solution I found, was starting MySQL from a script, which script contains commands, to set enviromental variables, and accesss these variables througg getenv() function from UDF.
If anyone has a better solution, I'm interested very much :-)

Is there a text based mysql UI?

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.

MySQL on Windows: Using SHA-2

I need to store sensitive data (usernames and passwords) and wanted to do things the right way (storing SHA-256 hashes of (password).(large random number) instead of cleartext passwords.
This needs to be done using MySQL and, as far as i know, only MySQL 6 plans to incorporate SHA-2, hence i assume some kind of external application needs to be setup; I would like to make a stored procedure that would calculate the hash of the password (concatenated with the nonce) and store it.
In your opinion, what would be the best way to implement this?
I've read a few post here on Stackoverflow and i'm currently heading towards Perl.
Cheers,
Hal
PS: OS -> Windows Server 2008
EDIT: damn editor, won't show the correct text. Fixed.
EDIT2: I am not trying to make my own version of SHA2, although it would certainly be fun; i need to use it on a stored procedure in order to hash the original password and I'm just not sure what external module/application/library I should use.
Your language of choice more than likely provides an implementation of SHA-256. Do not write your own implementation. That is just asking for trouble.
If you posted what your programming language is, I'm sure people would be more than happy to post back with links to documentation for that language.
PS: If you don't have a language in mind already, here's a PHP script I wrote a while back:
Ok, so apparently I lost it. But here is a simpler version:
<?php echo hash("sha256", file_get_contents("php://input"))."\n" ?>
And then you can call it like:
php hash.php
Then type in your information and close inpute (ctrl-x? on Windows)
MySQL 5.5 supports SHA2.
http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html#function_sha2