skip to Main Content

I am trying to export my database running this command :

sudo mysqldump -h wordpress -u root -p bitnami_wordpress >rescue2.database.sql

and got this error :

mysqldump: Got error: 2005: “Unknown MySQL server host ‘wordpress’
(-2)” when trying to connect

I am on a Debian 4.19.208-1 (2021-09-29) x86_64

Thanks for helping it’s been 2 weeks I am searching for…

2

Answers


  1. As suggested by Akina, -h specifies the IP Address of the host,
    for example localhost or any local ip on which the mysql server might be running.

    Refer below command for further usage.

    mysqldump -u [user name] –p [password] [options] [database_name] [tablename] > [dumpfilename.sql]
    

    or:

    mysqldump [OPTIONS] database [tables]
    

    where the [OPTIONS] can be (only some often used):

    • -h, –host=name Connect to host.
    • -p, –password[=name]
    • -u, –user=name User for login if not current user.

    for a complete list you can do: mysqldump --help, or take a look at the documentation

    Login or Signup to reply.
  2. Look at the file called wp-config.php at the top level of your WordPress installation. It contains lines like these:

    define( 'DB_NAME', 'my_wordpress' );
    define( 'DB_USER', 'EmileCantero' );
    define( 'DB_PASSWORD', 'some_secret_password' );
    define( 'DB_HOST', 'whatever.example.com' );
    

    Use that information in your mysqldump command like so

    mysqldump -h whatever.example.com -u EmileCantero -p my_wordpress >rescue2.database.sql
    

    Avoid running this as root (avoid sudo) unless you cannot get it to work any other way.

    A better way for most WP site operators: use one of the free WordPress backup plugins.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search