MySQL

Emulates a native MySQL client, with some additional features, and probably some missing:

  • The application gives you auto complete with suggestions when you type database, table, column, procedure and function names, just press TAB to complete a word.
  • You should set your username, password and hostname as the default in your TinyShell configuration file config.php, to avoid sending this information. For further information see section Security.
  • Commands can only end with semi-colon. If you need to have nested statements, like in a CREATE PROCEDURE statement, escape the statement with the special BEGIN_MULTI_STMT .. END_MULTI_STMT keywords. Notice: If you have more than one statement that is not nested inside these tags, only the first will be executed. Scroll down for example.
  • When using variables, all references have to be on the same command line, since the MySQL connection is not persistent. The connection is actually opened and closed on each request. Scroll down for example.

Command line interface

Syntax

  1. $ mysql [-u username] [--user=username] [-ppassword] [--password=password] [-h hostname] [--host=hostname]

Arguments

  • username – (string, optional) Username to connect with.
  • password – (string, optional) Password to connect with.
  • hostname – (string, optional) host to connect to, e.g. localhost.

Examples

Following is an example on a complex query, with multiple statements and one statement with nested statements inside a routine, in one command line. Furthermore the example illustrates, that variables can be used, if all references are on the same TinyShell line. This means: When you execute a command (by hitting enter) all previous variables or other temporary settings are reset.

  1. mysql> SELECT NOW();
  2. > BEGIN_MULTI_STMT
  3. > CREATE PROCEDURE dorepeat(p1 INT)
  4. > BEGIN
  5. > SET @x = 0;
  6. > REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
  7. > END
  8. > END_MULTI_STMT;
  9. > CALL dorepeat(1000);
  10. > SELECT @x;
  11. >
  12. +---------------------+
  13. | NOW() |
  14. +---------------------+
  15. | 2010-07-23 22:54:17 |
  16. +---------------------+
  17. 1 row in set (0.00 sec)
  18. Query OK, 0 rows affected (0.00 sec)
  19. Query OK, 0 rows affected (0.01 sec)
  20. +------+
  21. | @x |
  22. +------+
  23. | 1001 |
  24. +------+
  25. 1 row in set (0.00 sec)
  26. mysql>

Source code

You can see or download the latest revision from SourceForge:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>