0

I have been asked to take over development of a Delphi application that uses MySql 5.7.40. Amongst the information I was given was a dump of the database as an .sql file.

I installed MySql 5.7.40 (although I got version 8.0.31 of some of the related installs), and checked that it all seemed to work.

I then opened up the MySql Command Line Client, and entered the following...

source "C:\Users\Me\Downloads\Dump.sql"

However, this gave an error...

Failed to open file '"C:\Users\Me\Downloads\Dump.sql"', error: 22

I searched around and it seems that this error is caused by either having too many files open, or MySql being out of resources, or MySql not being able to find the file.

The first is unlikely to be the cause, as I am running MySql on a powerful machine with wads of memory, disk space, etc, and have tried restarting the device and doing nothing other than this command.

The only possibility I can see here is that the .sql file is 2Gb, which is maybe why it's running out of resources. However, I'm not sure if there is anything I can do to get around this, as the machine has 64Gb RAM, so any lack of resources is likely to be in MySql itself. Also, I tried creating a very simple .sql file that contained a single command to create a new database, and got the same error, so if it runs out of resources with a file of 35 bytes, then I'm doing something wrong!

The second seems unlikely, as I have checked and rechecked that the file path and name are correct. I've tried it with single and double quotes around the path, as well as both forward and backward slashes. Also, I tried moving my 35 byte .sql file to C:\ and had the same problem.

In case it helps, I'm running on Windows 11 64-bit.

Anyone able to advise? Thanks

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • This question has nothing to do with mysql server as the source command executes within mysql cli and cli has the issue of loading the file. – Shadow Jan 22 '23 at 23:05
  • @Shadow OK, thanks for fixing the tag. I'm new to MySql in general (decades of experience on other databases though) so wasn't sure – DelphiNewbie Jan 22 '23 at 23:13
  • Error 22 is a standard windows error message. Seems to be related to incorrect characters in the path (does not seem to apply here) or permissions related problems, if the file is on a remote computer. Does the path point to a OneDrive-synced folder? – Shadow Jan 22 '23 at 23:15
  • Or try to use \\ as separator in the path, not just \. – Shadow Jan 22 '23 at 23:19

1 Answers1

1
  1. Open a command prompt, and navigate to the folder where the .sql file is stored.

  2. Run mysql - you'll need to make sure the path is in your environment variable. It's probably something like C:\Program Files\MySql\MySql Server 5.7\bin

  3. Try just source Dump.sql (no need for quotes).

See if that works.

Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
  • Thanks! That sorted it. No idea why it failed with the full path, but I've got my database now, so no need to investigate further. – DelphiNewbie Jan 22 '23 at 23:25