Why is there an error with the source command in MySQL - 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

Related

Specific issue with migrating MySQL database into Digital Ocean

I'm pretty confused - I'm not too used to using command prompt for anything but I've recently been forced to do it as I'm trying to host my database with Digital Ocean.
I'm currently attempting to transfer my local database onto their servers by using the MySQL 8.0 Command Line Client.
The guide on their website says to use this command:
mysql -u doadmin -p -h mysql-test-do-user-4915853-0.db.ondigitalocean.com -P 25060 your_database_name \
< /path/to/database_file_name.sql
where the first part is the connection string that you get from their website and the second part is the file path on my PC.
I pass the connection string and it gives no errors, indicating to me that it's connecting to my database, but when I try to pass it a file path I get the following errors:
ERROR:
Unknown command '\U'
ERROR:
Unknown command '\J'
ERROR:
Unknown command '\D'
It seems like it's getting these strings from the file path, as if it's not recognising it as a file path but instead throwing errors.
I've tried putting just the file name on its own - nothing happens.
I don't even know the commands to check whether or not the tables have been added to my database.
The guide is not specific as to what the file path should look like.
Can anyone offer guidance? All I want to do is transfer my 6 tables into my new database (and rename the database, preferably).
Thanks,
Jordan

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.

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

Error code 1064, SQL state 42000: You have an error in your SQL syntax;

I'm using latest version of MySQL ==> mysql-5.6.10-winx64.zip
Created the database and every thing is ok 'I think'
when I try to execute this simple command;
"select * from family"
I got this error :
Error code 1064, SQL state 42000: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at
line 1
I've spent much time searching for a solution but no solution was found :(
That looks like an error coming from a JDBC driver. When the JDBC driver initializes the connection, it sends several commands to the MySQL server, one of which is:
SET OPTION SQL_SELECT_LIMIT=DEFAULT
The problem is that the SET OPTION syntax has been deprecated for some time and is now no longer valid in MySQL 5.6. Here's a relevant bug conversation from MySQL's bug database:
Bug #66659: mysql 5.6.6m9 fails on OPTION SQL_SELECT_LIMIT=DEFAULT
Try upgrading your JDBC MySQL driver. The bug conversation lists some other options in case upgrading the driver is not an option.
I followed the instructions above and this worked for me!
Download latest jar file from here:
http://dev.mysql.com/downloads/mirror.php?id=412737
Unzip it
Copy jar file "mysql-connector-java-5.1.25-bin.jar"
to this folder: C:\Program Files\NetBeans 7.3\ide\modules\ext
In Netbeans IDE: Disconnect from database.
Click Services. Expand Drivers. Right-click on MySQL and press Customize.
Add latest driver
Remove previous driver.
Re-connect to dabatase within IDE.
I had the same problem few weeks back. Followed the following steps and it very much resolved the issue.
Copied the latest version (mysql-connector-java-5.1.23-bin) of the jar file to ..\NetBeans 7.3\ide\modules\ext. My earlier version of the driver was mysql-connector-java-5.1.18-bin.
Change the driver version within NetBeans IDE. In the IDE's Services window, expand Drivers -> right-click on MySQL (Connector/J driver) and select Customize. Remove the earlier driver and point it to the latest one (C:\Program Files (x86)\NetBeans 7.3\ide\modules\ext\mysql-connector-java-5.1.23-bin.jar). Click ok and restart IDE.
This should resolve the problem.
If the driver suggestion does not work, check your sql for unprintable characters. I just spent an hour troubleshooting this issue only to discover a hidden u+200b character at the end of my sql statement.
I got the same Error when i was dumping mysql table structure file in to DB. Mistake was putting the Syntax for dropping all table before but not checking their existence in the Database.
Issue was at " DROP TABLE usermgmt".
I removed that code of lines of dropping tables and it proceeded with out any error this time.
I prefixed the name of the table with the database name such as
select * from database_name.table_name;
and it worked perfectly, so most likely there's a name conflict.

Trying to migrate SQL Server to MySQL using MySQL Workbench. Error: "[Microsoft][ODBC Driver Manager] Invalid argument value" when migrating data

Long time lurker, first time poster; hoping anyone can help me out.
Im using MySQL Workbench 5.2.41 to migrate a database from SQL Server to MySQL 5.0.8
The entire process goes smoothly: both SQL and MySQL connection Tests are good, the skemea and table create as expected, everything checks out until the 'Bulk Data Transfer' step. At that point I receive this error:
...
Migrating data...
wbcopytables.exe --odbc-source=DSN=SQL Server 11;DATABASE=;UID=sa --target=root#127.0.0.1:3306 --progress --passwords-from-stdin --thread-count=1 --table [GSAClosers_v2] [dbo].[AccountBase] `dbo` `AccountBase`
`dbo`.`AccountBase`:Copying 84 columns of 169530 rows from table [GSAClosers_v2].[dbo].[AccountBase]
ERROR: `dbo`.`AccountBase`:SQLGetData: HY009:10:[Microsoft][ODBC Driver Manager] Invalid argument value `dbo`.`AccountBase`:
Finished copying 0 rows in 0m00s
Copy helper has finished
...
For connectors I'm using Microsoft SQL Server / ODBC Data Source / DSN: SQL Server and for MySQL the IP and port(3306).
SQL Server 2012 Management Studio connects and all operations work as expected.
O, side not: both are on the same localhost machine.
If anyone can shed some light on this I would be forever indebted. Thanks in advance
From here:
[Microsoft][ODBC Driver Manager] Invalid argument value.
Regarding to the error message and code you provided, which seems is
database is invalid or cannot be accessed. That means either the
database does not exist or the user does not have permission to access
the database.
It turns out you need specify the instance after the server name, so
in the server name in the dialog box for creating the ODBC Data
Source, you must enter it as either: MyServer\SQLEXPRESS or
.\SQLEXPRESS
I think you may have a problem connecting to your database from wbcopytables.exe. Keep in mind that this is a separate tool so the fact that you can connect from the rest of the Migration Wizard doesn't imply that you will connect in wbcopytables.exe.
The thing that worries me the most is that your DSN has whitespace characters. This might be interpreted by the Windows terminal as independent command line parameters. One thing you can do is to edit your DSN name removing the whitespaces and try again.
You may also want to connect without a DSN by putting all your connection parameters explicitely as explained in my blog post: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
And, by the way, since MySQL Workbench 5.2.42 is out you should go and get it. The Migration Wizard is pretty new so important bug fixes are likely launched in each recent Workbench release.
In either case I think you should file a bug with your issues with a detailed explanation about how to reproduce it, possible solutions, etc.
Hope this helps.
Ok, got it figured out: un-install java. install java 1.6, use MySQL Migration Tool. change all data types to varchar, ints and bits. run migrations....eat data.