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
Related
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
I was trying to automate our form compilation process.
I created a .bat file that will do the following:
Login user to host
sudo -S -u oracle bash -c 'bash /frmcmp_batch.sh'
But when I try to run frmcmp_batch.sh, I'm getting the error:
FRM-91500: Unable to start/complete the build error.
It is because your display isn't right. You get this to work by setting the following commands:
export TERM=vt220
export ORACLE_TERM=vt220
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...
I'm attempting to setup postgres 9.6 on ubuntu/vagrant through a provisioning script. Part of my script adds a line to pg_hba.conf with the following command:
sudo -u postgres echo "host all all all md5" >> /etc/postgresql/9.6/main/pg_hba.conf
However, this gives me the error -bash: /etc/postgresql/9.6/main/pg_hba.conf: Permission denied
Which is strange because I am allowed to edit the file with either sudo nano or sudo -u postgres nano.
Here are the permissions on the file:
-rw-r----- 1 postgres postgres 4641 Apr 6 16:11 pg_hba.conf
How can I add this line to my configuration file in a script?
The problem here is that redirection happens before command execution. So the redirection doesn't have the elevated privileges you expected it to.
There's more than one way around that problem. I generally use something like this.
echo "host..." | sudo tee -a /etc/postgresql/9.6/main/pg_hba.conf
Piping to sudo tee... avoids problems with quoting.
How bash executes commands
Redirections
I can't figure out how to read content of a file from a Docker container. I want to execute content of a SQL file into my PGSQL container. I tried:
docker exec -it app_pgsql psql --host=127.0.0.1 --username=foo foo < /usr/src/app/migrations/*.sql
My application is mounted in /usr/src/app. But I got an error:
bash: /usr/src/app/migrations/*.sql: No such file or directory
It seems that Bash interprets this path as an host path, not a guest one. Indeed, executing the command in two times works perfectly:
docker exec -it app_pgsql
psql --host=127.0.0.1 --username=foo foo < /usr/src/app/migrations/*.sql
I think that's more a Bash issue than a Docker one, but I'm still stuck! :)
Try and use a shell to execute that command
sh -c 'psql --host=127.0.0.1 --username=foo foo < /usr/src/app/migrations/*.sql'
The full command would be:
docker exec -it app_pgsql sh -c 'psql --host=127.0.0.1 --username=foo foo < /usr/src/app/migrations/*.sql'
try with sh -c "your long command"
Also working when piping backup to the mysql command:
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
You can use the database client in order to connect to you container and redirect the database file, then you can perform the restore.
Here is an example with MySQL: a container running MySQL, using the host network stack. Since that the container is using the host network stack (if you don't have any restriction on your MySQL or whatever database), you can connect via localhost and performing the commands transparently
mysql -h 127.0.0.1 -u user -pyour_passwd database_name < db_backup.sql
You can do the same with PostgresSQL (Restore a postgres backup file using the command line?):
pg_restore --host 127.0.0.1 --port 5432 --username "postgres" --dbname "mydatabase" --no-password --clean "/home/dinesh/db/mydb.backup"
Seems like that "docker exec" does not support input redirection.. I will verify this and maybe open an issue for Docker Community at GitHub, if it is applicable.