How to exit "->" in macOS terminal for mysql? - mysql-cli

I was testing commands like "status" for mysql, then I suddenly entered this mode I don't recognize. Can not do anything from here. Whatever I entered, it's just roll into next line.

use exit or quit and also \qto leave the mysql shell
see manual
To get to the next command you can use ; semicolon like you end all sql comands

You need to complete each command with a semicolon. So just type a semicolon and return and your command will be executed

Related

Why does " ^C " appear on putty and makes me write the mysql code again?

As you see, the first time I wrote the code, the ^C appeared. Then I had to write exactly the same again and then everything worked completely fine. What is wrong?
^Cis the command to end a process running in the CMD
https://learn.microsoft.com/en-us/windows/console/ctrl-c-and-ctrl-break-signals
Whenever you will use Ctrl + c while using terminal or command prompt, control return will occur.

Embedding shell command in perl program

How can I embed a command like mysql -sN -e "query;" inside a perl script so that my shell will be the one making the database connection. The query is a little complicated query which runs perfectly from the command line but when I set it up in my perl program, i get a bunch of errors like "string found where operator expected" , "bareword found where operator expected" and syntax error. Any idea how to do this without making giving perl access to the database?
You can use back quotes, the example below will place the output of the OS ls -l command into content. Assuming you know the risks of what you are doing.
#!/usr/bin/perl
use strict;
my $content=`ls -l`;
print $content;

InstallShield 2014, Custom Actions and executing sql files into MySQL

I am building an installer for our product which works well. I've managed to build custom actions to install our services including a MySQL server.
The problem I have is executing a sql file to build the schema structures.
I have a custom action which uses mysql.exe and the command line arguments:
--port=### --user=### --password=### < "[INSTALLDIR]db\EmptyStruct.sql"
It tries to execute this ok but the cmd window which pops up, during the install, just runs through the mysql.exe command line options, which says to me that the command line it gets passed is not correct. However if I run the command manually after the install, it works perfectly.
Does anyone has any ideas please.
I'm making a few assumptions here:
You have a Windows Installer exe custom action that specifies mysql.exe and a command line as you showed
You are expecting the contents of [INSTALLDIR]db\EmptyStruct.sql to be redirected to mysql.exe's standard input
This will not happen. Behind the scenes, Windows Installer's exe custom action support uses the CreateProcess API and this API will interpret command lines literally. However the redirect < needs special handling to actually perform redirection.
To get that behavior, you must use a layer of indirection. For example, you could run cmd.exe as the exe, and give it a command line that will make it interpret and run the command line mysql.exe --port= ... < "[INSTALLDIR]...". However, if you didn't already have a command prompt showing, this would cause one to show up. If you want to avoid that, you could write a custom wrapper that performs the redirection for you, either as a C++ DLL or, say, InstallScript action.
Alternately, if there is a parameter that tells mysql.exe to run a script from a file, you could pass that instead of using redirection. I wasn't able to find evidence of such a parameter in a quick web search.
Thanks for your comments Michael and I used cmd.exe /k AddStruct.bat to accomplish the task!

why does "gcloud dns records --zone="imaginout" edit" fail on OSX?

On OSX this brings up a vi editor. You can write the file and exit but it will still fail then output a long error stack. If you then do "echo $?" it outputs 1, indicating that vi returned an error status.
The problem may be that your ~/.vimrc is causing an error in the legacy vi editor. Try moving the .vimrc to another name then run the command again. Fixed it for me.

Execute batch file with arguments

I'm working on a project that require me to use window task scheduler to execute mysql query, this is the batch file content:
mysql -ufoo -pbar -D %1 < %2
when I tested the batch file via cmd:
task_sheduler.bat dbName pathToSqlFile
I get:
mysql -ufoo -pbar -D dbName 0<pathToSqlFile
I just want to say that its working, my question is what is about the extra space and the 0, where did they came from?
The extra space is between the dbName and 0
I'm using Windows 7 Ultimate Service Pack 1 (x64)
I assume your Batch file does NOT have an #echo off command, so you refer to the echo of commands that appear in the screen when a Batch file is executed. The display of these commands frequently include additional characters that cmd.exe inserts to display exactly the executed commands.
In the case of redirections, <input is a short form of Stdin redirection, and the number of Stdin is zero, so the real redirection is 0<input. The same happens with >output, that is echoed as 1>output. cmd.exe also remove multiple spaces from the original code and insert needed ones in order to clearly show the executed commands.
If you want not to see these command expantions, just insert an #echo off command at beginning of your Batch file.
cmd prefixes all redirection commands by the default handle if none is provided. The handles are defined here. 0<file thus means that we want file to be redirected to standard input. The extra space is there to prevent a command like hi.exe<myfile from being wrongly interpreted as hi.exe0 < myfile