I'm helping a non-profit organization with a large website they run. Their current host/developer hasn't responded to them in over a year. They want to get their files and database and move to a new host.
When I load the phpMyAdmin page and try to log in, it returns the following error.
#2000 - (mysqlnd_ms) Exclusive usage of configuration enforced but did not find the correct INI file section
What could be causing this? Is there a problem with the php.ini configuration?
Thank you for your help.
mysqldump recipe:
SSH in using the website user (or root and then su to website user)
cd to the public_html or httpdocs folder cd httpdocs
mysqldump -cuUSER_NAME -p DATABASE_NAME -eqQc > filename.sql
(USER_NAME is MySQL connection user name, if you don't have it and DATABASE_NAME try downloading all the script files for the site and looking through them for MySQL code.)
Optional : gzip -9 filename.sql
Download filename.sql or .gz with your FTP program. 7-zip can extract from .gz files.
Related
I am attempting to back up a MySQL database on a Linux server before I install some upgrades to the software (Omeka) which is using the database.
The command supplied by Omeka documentation for that is the following:
mysqldump -h localhost -u username -p omeka_db_name > omeka_db_backup.sql
However, when I run this, I get the ever so helpfully vague message of "permission denied." It does this if I run the command as sudo. It does this no matter what directory I try to save the backup file to. It doesn't prompt me for a MySQL password when I run mysql dump, but it does when I run "mysql" command and it accepts the password I put in so I know the issue isn't that I'm using the wrong credentials.
I cannot navigate to the MySQL folder directly in shell and when I use WinSCP to access the server, the MySQL folder is listed as owned by "MySQL" and not by "root." So I'm assuming that I don't have permission to copy anything from this folder and that is my problem. I don't want to willy nilly assign ownership of the MySQL folder to root because I'm afraid it might break MySQL's ability to read and write from this folder.
All I want to do is copy the database files somewhere as backup. Heck, I'll copy the whole MySQL folder someplace if I have to do that. How can I do that without breaking MySQL?
Root has permissions for everything. There may be some additional safeguards, depending (there is some security software that limits root permissions).
You can just use:
mysqldump -h localhost -u username -p omeka_db_name > /path/to/some/other/directory/omeka_db_backup.sql
And put backup in directory you can normally access. If you use the mysqldump you don't need to write to mysql dir.
I have a local copy of Bitbucket Server on my machine and i'm running tests before putting it on a server.
I'm trying to use the Bitbucket DIY Backup but every time I run the backup it completely deletes the directory the database should be backed up into and then tells me is cannot find the directory.
It backs up to the home and archive directories as it should with no issues but won't work for the database.
Here is the line used for creating the dump that seems to be causing the directory to be deleted:
mysqldump -username=root -password= --databases=bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql
I have tested the connection settings on the line above with the following line and am getting a list of the tables in the database as I would expect:
mysql -D bitbucket_server -u root -p -e "show tables"
Any help would be greatly appreciated, thanks in advance.
Sam
I have stopped the bash file from deleting the directory and now it stores the dump in there.
Thanks to #BerndBuffen I altered the way the dump was accessing my database. Instead of using:
mysqldump -username=root -password= --databases=bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql
I now use:
mysqldump -uroot bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql
You also need to add the following code to the line above mysqldump to create the folder:
mkdir -p ../bitbucket-backups-diy/bitbucket-database
Because my root user doesn't have a password on my local database I don't need to list a password, this looks to be the reason it was failing. For when I put the backup on to a live server I will just need to add -p back in to the script and it should work.
Hopefully this can help anyone else having this problem.
Sam
I want periodic mysql database backup. But I don't have permission to access ssh. When I try to run mysqldump via command line in Plesk Scheduled Tasks, it only creates a blank file 0 kb sized. I'm not sure if the system finds mysqldump when I write it in command line. How can I be sure mysqldump file exists in my server? How can I find its path? It doesn't exist in bin or usr folders. Is there a way to access this file? I can backup database via PhpMyAdmin manually. But I want periodic backups. Thanks.
Osman.
You can try to create a php script with the following code block:
<?php echo `which mysqldump`; ?>
Please note, those are backticks.
This may or may not work depending on whether or not open_basedir is setup on the server. This can give you the absolute path to the mysqldump binary, which you can then reference in the plesk sched. task.
Since you don't have control over the server, if the above doesn't work, you'll need to ask the server owner to either grant you access to mysqldump or use phpMyAdmin (assuming your dataset isn't too large).
This worked for me...
exec('complete\path\to\mysqldump.exe -uUSERNAME -pPASSWORD DATABASE_NAME > output_folder_path/filename.sql');
if u want the path goto your wamp folder & search for mysqldump.exe
Currently I am learning MySql using commandline in ubuntu and made a backup of my database named 'sandwich' using mysqldump command.
mysql> #mysqldump -u root -p123456 sandwich > db_backup.sql;
Where I can find this 'db_backup.sql' file on the disk. Please tell me a specific file path where i can find this file.
It depends where you were when you executed the command - db_backup.sql will be found there as you didn't specify a full path.
Try your home dir or the web dir if you can't remember - anywhere you might have been when entering mysql. If all else fails you can use find:
find / -name 'db_backup.sql'
this may take some time so if you can narrow down the area of search and replace / with ~/ for example, that would help.
run following command without logging into mysql terminal.
mysqldump -u root -p db_name > db_dump.sql
It will ask for password. Enter password.
When dump is complete type following command.
ls
You will see db_dump.sql file in the list.
I'm creating a snippet to be used in my Mac OS X terminal (bash) which will allow me to do the following in one step:
Log in to my server via ssh
Create a mysqldump backup of my Wordpress database
Download the backup file to my local harddrive
Replace my local Mamp Pro mysql database
The idea is to create a local version of my current online site to do development on. So far I have this:
ssh server 'mysqldump -u root -p'mypassword' --single-transaction wordpress_database > wordpress_database.sql' && scp me#myserver.com:~/wordpress_database.sql /Users/me/Downloads/wordpress_database.sql && /Applications/MAMP/Library/bin/mysql -u root -p'mylocalpassword' wordpress_database < /Users/me/Downloads/wordpress_database.sql
Obviously I'm a little new to this, and I think I've got a lot of unnecessary redundancy in there. However, it does work. Oh, and the ssh command ssh server is working because I've created an alias in a local .ssh file to do that bit.
Here's what I'd like help with:
Can this be shortened? Made simpler?
Am I doing this in a good way? Is there a better way?
How could I add gzip compression to this?
I appreciate any guidance on this. Thank you.
You can dump it out of your server and into your local database in one step (with a hint of gzip for compression):
ssh server "mysqldump -u root -p'mypassword' --single-transaction wordpress_database | gzip -c" | gunzip -c | /Applications/MAMP/Library/bin/mysql -u root -p'mylocalpassword' wordpress_database
The double-quotes are key here, since you want gzip to be executed on the server and gunzip to be executed locally.
I also store my mysql passwords in ~/.my.cnf (and chmod 600 that file) so that I don't have to supply them on the command line (where they would be visible to other users on the system):
[mysql]
password=whatever
[mysqldump]
password=whatever
That's the way I would do it too.
To answer your question #3:
Q: How could I add gzip compression to this?
A: You can run gzip wordpress_database.sql right after the mysqldump command and then scp the gzipped file instead (wordpress_database.sql.gz)
There is a python script that would download the sql dump file to local. You can take a look into the script and modify a bit to perform your requirements:
download-remote-mysql-dump-local-using-python-script