Database Backup with additional params using ansible [closed] - mysql

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 days ago.
Improve this question
We currently use an ansible script to back up data from our MySql-5.7 database instance.
- name: backup
mysql_db:
state: dump
name: data
target: "/tmp/data-{{ ansible_date_time.date }}.sql.gz"
login_user: "{{ login_username }}"
login_password: "{{ login_password }}"
We have now transitioned over to CloudSql MySql-8 and a successful backup, from the command line, uses the following parameters:
mysqldump --defaults-file='/mysqldb/.database.cnf' -h 10.x.x.x data --max_allowed_packet=32M
--routines --triggers --single-transaction --set-gtid-purged=OFF --opt > /backups/backup-$(date +\%d\%m\%Y).sql
The previous backup module will not work as additional parameters have to be set.
Is this the correct ansible documentation listing how to add aditional arguments:
https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html#parameter-dump_extra_args
It doesn't really specify how to add the additional arguments.
Any thoughts?
Any info is appreciated.
Roland

Related

Command for dropping a specific MySQL database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
In phpmyadmin, we can drop a specific database from operation tab and by hitting "DROP THE DATABASE (DROP)". But I need to drop a specific database using command prompt or terminal.
Use mysqladmin like
mysqladmin -uroot -pyourpassword drop database_name
In this case User: root with password: yourpassword will delete database database_name
You will get a warning and have to verify it
You can try this
DROP DATABASE database;
https://dev.mysql.com/doc/refman/5.7/en/drop-database.html

Mysqldump not working in jenkins execute shell [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have a shell script that is running as a cron job, which creates a database dump for backup purposes. When I tried doing the same in a Jenkins execute shell, the following line seems to be giving errors:
mysqldump -p thepassword -u theussr --all-databases > databases.sql
What happens is that the following error gets into the databases.sql file:
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
I am confused as what is going wrong here. I tried with "-r databases.sql" and the file comes out empty with the error being printed in the console.
For me, this works in Jenkins:
mysqldump -hxx.xx.xx.xx -pmy_pwd -umy_user db_name > ${filename}
I am generating the file name with time stamp, like:
filename=$(date +'%Y%d%m-%H_%M').sql
My problem was the space in -p mypassword, however with removing the space it did not work either.
Finally this helped resolve the issue:
export MYSQL_PWD=yourverysecretpassword
mysqldump -u theussr --all-databases > databases.sql

Mysql dump code using perl script [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to do the mysql-dump using perl script.Backup from some tables from mysql database in perl script.
system(mysqldump -u username -pPassword databasename database table > to /local path) or die..;
Tell me this line which will store backup file of tables to the local path.
Have you tried running that line from the command prompt? It looks like it should work. Are you putting the command in quotes?
system('mysqldump -u username -pPassword databasename database table > to /local path') or die('This failed');

Mysql large table export size of 3GB [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need to export a table of size 3GB to another database. Both are on different server.
When i tried to export using phpmyadmin tool, It leads to server error.
Also both database are on different servers. I need to export and import into other server.
Please advise.
Use mysqldump if that is a possibility, archive it and copy it afterwards to the new server.
If mysqldump is not accessible, phpMyAdmin has a feature to export it already archived ... try with that.
MySQL provides a tool exactly for this purpose:
commandline_of_your_choice#> mysqldump -uusername -p -hlocalhost DB_Name --single-transaction | mysql -uusername -p -hremotehost DB_Name
Simple as that :)

connecting to a mysql database remotely [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What I would like to do is connect to a database that runs a website. Then copy the contents of that database to another database, on a different server. Can this be done?
It can be done and there are different ways to do it. I'll list 3 different ways
Run mysqldump -h<source host> | mysql -h<target host>. You'll have to read up on the mysqldump options to decide which you need to add and you probably need to put options for user, password and databases as well.
Copy all files that mysql uses and put them on the new host. As long as the new server is configured the same way it will work
Use Perconas xtrabackup. This is probably the best option if the database is large. The database can still run while the backup is being made. This option will create an exact copy of the database and that may or may not be wanted.
Generally if the database is small option 1 is easiest.
Yes, but it depends on how the database is set up.
Most databases that run behind a web server will not be accessible externally, for security reasons. Your best bet, assuming you have access to the server, is to login to the shell and dump the database. MySQL has the tool mysqldump to help with this. In a pinch:
mysqldump -u username -p schemaname > yourdatabasedump.sql
Alternatively, you could install PhpMyAdmin on your server (assuming PHP is enabled) and dump the database from there.
Importing is the opposite. Get shell access on the other server and do something like this... First, create your schema:
mysql -u someuser -p
> CREATE DATABASE schemaname;
> exit
Then import.
mysql -u someuser -p schemaname < yourdatabasedump.sql