No system command when using mysql from cli - mysql

Attempting to change directories, view directory contents, etc., but for some reason I don't have the system command to use the command line once I run mysql. These are the options I get:
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
notee (\t) Don't write into outfile.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
Any ideas what could cause this? It seems to be possible using windows (using \!).

As stated in the MySQL documentation, the MySQL system command works only in Unix and therefore not in Windows:
http://dev.mysql.com/doc/refman/5.6/en/mysql-commands.html

Related

Access Azure MySQL database using workbench when azure cloud shell works

I keep getting the following error when attempting to connect to an azure MySQL database using MySQL WOrkbench
I have set the security options as follows:
Basically allow all IP addresses.
I can access it using azure cloud shell:
sean#Azure:~$ mysql --host XXXX.mysql.database.azure.com --user XXXX#YYY -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 65490
Server version: 5.6.39.0 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> help
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.
For server side help, type 'help contents'
mysql>
But I can't connect from my PC using workbench. I can use workbench to connect to another database using 3306 so the port is not blocked.
I'm convinced I have done something wrong on azure but don't know what it is. Any ideas?
Microsoft documentation about how to connect with workbench:
https://learn.microsoft.com/en-us/azure/mysql/connect-workbench
How to configure SSL:
https://learn.microsoft.com/en-us/azure/mysql/howto-configure-ssl
I think your forgot to do this part.
I decided to use a bitnami MySQL instance but ran into problems too (Authentication plugin 'caching_sha2_password' cannot be loaded). I came across a tip to upgrade Workbench.
The tip didn't work but it did fix my original issue with the azure database.
The solution: upgrade workbench.
Honestly, I think this is ridiculously stupid. Why don't they have a validation tool that can be run after launching an instance? It would probably take a day to engineer...

Delphi + MySQL command line

I'm building a tool using Delphi and MySQL to restore a script generated with MySQLDump.
It was supposed to load and execute a SQL file and log any possible errors into a given output file.
I thought about execute the mysql command line and send command lines but i don't know if its possible ou how to do it since I just know how to call mysql using windows cmd and execute a single command line using ShellExecute or CreateProcess
I tried to do it with a single command line but it did'nt logged the errors properly
I tried this:
cmd /c mysql.exe --user root < "C:\restore.sql" > "C:\restore_log.txt"
the content of restore.sql was:
drop database test;
It does execute my script, but on the second attempt it should log "database doesn't exist" but restore_log.txt was empty
It would help if anyone could point the way to call mysql and send multiple lines OR a help with my cmd line to log properly
Anyone can help me?
I don't know what components you've got available to connect to the MySQL db, but using TADOQuery to access SQL Server, I simply load up the queries into a TADOQuery's .SQL property and then call Open or ExecSQL. As long as it's just vanilla SQL that was generated by SQLDump, I'd guess that should work. It's worth a try anyway.
digging more at stackoverflow I found previous answers that helped, the difference is that the output goes to a Memo that I can save to a file.
Thank you all for the help and the insights.
The answers can be found on the following links:
Getting output from a shell/dos app into a Delphi app
How do I run a command-line program in Delphi?
Getting output from a shell/dos app into a Delphi app

How to work with emacs and mysql

I'm getting the message unable to locate SQL program 'mysql' when I attempt to enter sql mode in Emacs. However, I'm able to access mysql just fine via terminal.
For the record, I'm using user and password as root, server as localhost and a database of my choosing. I just don't know why this is happening.
Ideas?
Emacs uses the directories listed in the exec-path variable to look for programs. You can add to it like so:
(add-to-list 'exec-path "/usr/local/bin")
The following shell command should give you the correct value to use:
dirname `which mysql`

WAMP phpmyadmin 414 error

i am getting the error as follows.
414 Request-URI Too Large
need to change wamp settings from get to post. how can i do this?
i am using my wamp server to execute an import query on a very large data.
thank you.
If your database is very large it is much better to use the command line processor.
Go to wampmanager -> MySQL -> Mysql console
This will open a command window and log you into the mysql command processor. You may need to enter the password for 'root' or leave it blank if you have not set one yet.
Then use this command to get the mysql processor to read your backup file and execute all its commands :
source /path/to/your/backup/file.sql
simple and it will run for as long as is required to complete the restore.

Call mysql SOURCE command from a C program

I want to execute some mysql statements that are stored in a text file from my C program using the mysql.h library.
My inclination was to do something like the following, but this doesn't work:
mysql_query(conn, "source test.mysql");
This is because the SOURCE command is not a mysql statement in and of itself.
Is there a way call the SOURCE command programmatically and not from the command line?
The source command is a built-in command in the mysql client program, it isn't a SQL command. Your best bet is to either call the mysql client program using the C system function (or an equivalent), or read the file text file yourself a command at a time and pass them to your query function.