Delphi + MySQL command line - mysql

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

Related

what should i do to run 'mysql --versi' command in my terminal

What should I do to run the 'mysql --version' command in this way and not get an error?
I want to code MySQL via VS Code. What do I need for this? I did some research, but the commands are constantly given to the terminal using the 'mysql' command. But when I type this command, I get an error like this. Could you help. My goal is to code MySQL on VS Code.

Why is there an error with the source command in MySQL

I'm trying to add the employee sample database for practicing with MySQL however there's an error since there's a source command and from what I've found it says that MySQL doesn't support this command anymore.
So, how could I add the complete database without any error?
[this is the code line where the source command is called]
SOURCE is one of the mysql client builtin commands. These are recognized by the mysql client, but not by the MySQL Server's SQL parser.
See https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html

How to fix en error when running an SQL Script in MySQL Workbench?

I made an SQL Script (I checked it for errors and everything was fine). After that, I opened it in MySQL Workbench. I wanted to run it to view my query results. I clicked: File - Run SQL Script. I selected my file and it came up with an error:
error calling Python module function SQLIDEUtils.runSQLScript
What should I do to successfully run my script file?
In the MySQLWorkbench, instead of File > Run SQL Script, could you try to use File > Open SQL Script followed by Query > Execute (All or Selection)? This way, you should see an output from each query of the schema.sql script.
You could also try to use the mysql command (from a command line) instead. Or, splitting the schema.sql into smaller chunks to isolate the problem.
If nothing work I suggest you check the MySQL Workbench installation.
i think you are not logged in mysql server
solution
after downloading mysql workbench and mysql server
2.when you are open mysql workbench left-downside see there mysql connections click on that
3.enter username and password
4.query Execute-all will start working
I also had this problem, turns out I was simply not connected to the Local instance of MySQL. All I had to do was open MySQL Workbench > Toolbar > Database > Connect to Database > Stored Connection (choose local instance mysql) > ok. If it asks for root password, it's just your windows user password.

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.