mysql can source sql file but mysqlsh can not - mysql

I am using mysqlsh to connect to mysql database running in docker container.
I can source sql file using sql; but can not source exactly same file using mysqlsh.
I googled for the solution yet to find the one.

Related

Shifting database from MySQL to Postgres

I have a database in MySQL which can be accessed using Microsoft SQL Server Management Studios. I have a .bak file of that database and I want to shift this database to Postgres.
I went to the command line and I opened the directory of my Postgres to the bin folder from the program files, and I wrote the command :
psql -U postgres -d postgres < (directory of the .bak file)'
I got the following error on running the above command:
ERROR: syntax error at or near "TAPE"
LINE 1: TAPE
Can someone please explain why I am getting this error and how to resolve it?

How to Export MySQL Database From Digital Ocean Managed Database

I have a MySQL database hosted on Digital Ocean Managed Database service. I lost my previous dev machine and did not push the Schema to git along with application files. I am desperate to get back the SQL Schema in my local machine for further Development but have so far been usuccessfull. I have tried so many commands from different suggestions but they all failed.
I connect to the DB via the MySQL Shell using the command:
mysql -u username -password-h example-test-do-user-7878789-0.b.db.ondigitalocean.com -P 25060 -D example_db
All queries are executed successfully via this shell method. When trying to Dump the Schema to my machine, I use the following command:
mysql -u username -p -h mysql-test-do-user-4915853-0.db.ondigitalocean.com -P 25060 your_database_name \> database_file_name.sql
But I get the error as follows: mysqldump: unknown variable 'set-gtid-purged=OFF'
if I remove that part and try again, I get the error:
mysqldump: Got error: 2003: "Can't connect to MySQL server on 'localhost' (10061 "Unknown error")" when trying to connect
which doesnt make sense to me. So, without further ranting; How to I achieve my intended result.
NOTE: I did try Mysql workbench, but it won't connect all together
I can appreciate trying to achieve what you want via mysql shell. I stumbled across the same problem and for quite some tie did not find the help i needed, then I tried doing it using mysql workbench. Try it and you will find that its easier than usin the command-line approach. MySQL Workbench has a good GUI based database miguration capability. You can migrate you Do Managed DB directly into you local mysql server or export a schema dump. If you decide to go wit this approach, just make sure you add your machine's IP as a trusted source, else you will not be able to connect.

Export MySQL as CSV using Powershell

I am trying to extract a certain table as csv using powershell, since this task is scheduled. Since using it in Powershell is basically the same I am showing you the commandline commands I tried using:
mysql --user=root --password=root apps_monitor -e "select * from board into outfile 'C:\Temp\export.text'"
And then I get the error:
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
My question is how I disable this option. I tried editing the my-default.ini in the MySQL Server directory and adding
secure_file_priv=NULL
And
secure_file_priv=""
But both did not do anything upon restarting the mysql service. Can someone please help me with that thing.

Importing sql file into Mysql running xampp using commandline in Mac

I have installed xampp in my macosx and i want to import the wordnet sql file its not working. i tried this command
/Applications/XAMPP/xamppfiles/bin/mysql -u root -p dict < wordnet20-from-prolog-all-3.mysql
The commandline works without any errors takes a while to finish.
I fireup phpmyadmin and check the dict database and nothing is there. What is the problem?
In your .sql file, look for a USE statement that would switch execution to another database. It might explain why you see nothing in the database used on the command line.

Where can I run a mysql command line under Azure to fix "The used command is not allowed with this MySQL version (1148)"

I have a MySQL database which is hosted in Azure, and I have MySQL Workbench installed on my laptop. I want to do some importing from a CSV file located in my laptop, but whenever I try to that, I get an error message saying:
The used command is not allowed with this MySQL version
I did some online searching, and I found out that I need to run the following command:
mysql -u myuser -p --local-infile somedatabase
But, I don't know where I have to run it, and how, while as I said my database is hosted in Azure.
mysql is just the commandline executable of the MySql client. And most probably it is even part of the MySql workbech - just check the MySQL Workbech working folder. But the result will not be different is my guess.
The best way you can manage Import/Export for MySQL is to use a Free Tier WebSite and Install the phpMyAdmin extension.