How to read .sql file by dictionary on MacOS? - macos

I got error 2 when exec sql file by dictionary
I tried to exec mysql file on Mac OS at this dictionary: "/Users/kato/Desktop/world_mysql_script.sql"
source /Users/kato/Desktop/world_mysql_script.sql;
Then I got this error:
Failed to open file '/Users/kato/Desktop/world_mysql_script.sql', error: 2
Do you have any solution?
1.

Please try to use mysql command.
mysql -u DB_USER -p -h DB_HOST DB_NAME < /Users/kato/Desktop/world_mysql_script.sql

Related

run bash script containing postgresql script failed

I have already create bash script containing sql script (postgresql), but failed.
owner the file : postgres:postgres with 777 (chmod), but when I execute with "./bash1.sh" error: psql: FATAL: role "postgres" does not exist
the bash script:
#!/bin/sh
THE_DATABASE=epolicy
MY_TABLE=hpx_sms
psql ${THE_DATABASE} <<THE_END
SELECT * FROM ${MY_TABLE};
THE_END
how to fix this problem? or any reference? thank you.

Importing a database dump -- PSQL

I am trying to import an old .gz database dump into my database using the terminal. It is a Postgresql environment.
This is what i am doing:
psql test < 052710_1.gz
Responce:
ERROR: syntax error at or near "test"
LINE 1: test
^
I also tried:
psql --dbname test < --file 052710_1.gz
psql -d test -U postgres -f 052710_1.gz
And they both gave me the same error.
I have tried using the .exe on the end of psql and it has the same issue.
I am running Postgresql 10.1
For the case of version 10.1
try using the following command
pg_restore -d test < 052710_1.gz
Hope this works.
Please follow the commands. Hope it will works.
sudo psql -U postgres
 create database temp_databse;
 exit
Execute following command
 
psql -U postgres temp_database < extracted_database_file_name
 Above command will restore database...

-bash: mysqldump: command not found MAC OS X

I want to export and import a .sql file from MySQL server from to my machine with a command line:
/Applications/MAMP/Library/bin/mysqldump -P 3306 -h server -u login -p passwd database > db_backup.sql
But I get this error:
-bash: /Applications/MAMP/Library/bin/mysqldump: No such file or directory
It work well now, I just changed:
/Applications/MAMP/Library/bin/mysqldump
by:
/Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump
XAMPP includes all of the MySQL binaries:
/Applications/XAMPP/bin/mysqldump

rake db:structure:dump fails postgresql no such file or directory pg_dump

I want to create structure.sql of existing schema. but getting same error while executing db:structure:dump
No such file or directory - pg_dump -i -s -x -O -f F:/Workspace/TestApp/db/structure.sql db_name
I tried deleting schema.rb and chnages schema format to :sql, But it did not work either.
How to deal with this?
Got the issue...
I just have to add postgres to PATH env variable, after that it worked..

run my sql dump in terminal

so I have can create a dump
/Applications/MAMP/Library/bin/mysqldump -u admin -p testsite > yourdump.sql
but how do I run this on another mac in terminal?
I should be as simple as running this:
mysql -u<user> -p dbName < db_backup.dump

Resources