• Resolved paul

    (@paul)


    In an effort to recover my database, I was able to get it stuffed into mysql/mariadb but for some reason I can’t get wordpress or the wp cli tool to access it. I can log in vi the mysql as root or a non-privileged user but wp and wordpress both complain about being unable to make a database connection. Is there a trick to this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Yes, this is possible but the table prefix needs to be different for each site.

    On another note, I do not think this is a good idea. Additional databases do not cost you anything and saves you from a lot of hassel.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    As Sekander said, it’s certainly doable, but there’s a security issue. If siteA and siteB both use the same database (dbA) with different table prefixes, then siteA has access to siteB’s tables, and vice-versa. It’s best to use two different databases with different users.

    Thread Starter paul

    (@paul)

    They are in separate databases within the same instance of MariaDB, with their own name and table prefix and their own authentication credentials.

    I can login to both using the mysql/mariadb client from a non-privileged account but both wordpress and the wp app fail to connect to the second one. Not that it matters but the second one is only there to allow me to recover from a crash in an earlier version of the site. Once I have the data cleaned up, I can re-import it into the new one that only has a subset of the data.

    So why does wordpress/wp ignore the credentials in wp-config.php from the directory when run from the directory where it appears?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Check wp-config.php on the site that doesn’t work and validate (or just re-type) the DB_* values.

    Thread Starter paul

    (@paul)

    It would be useful if the debug switch on the wp client displayed those values as part of the validation. Right here would be good:

    Debug (commands): Adding command: help (0.099s)
    Debug (bootstrap): No readable global config found (0.1s)
    Debug (bootstrap): No project config found (0.1s)
    Debug (bootstrap): argv: /usr/local/bin/wp --allow-root --debug (0.1s)
    Debug (bootstrap): ABSPATH defined: /usr/local/www/crank/ (0.1s)
    Debug (bootstrap): Begin WordPress load (0.1s)
    Debug (bootstrap): wp-config.php path: /usr/local/www/crank/wp-config.php (0.1s)
    Debug (hooks): Processing hook "before_run_command" with 1 callbacks (0.133s)
    Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (0.133s)
    Debug (bootstrap): Running command: help (0.133s)
    
    Thread Starter paul

    (@paul)

    Well, this works but it seems less than ideal:

    [root@www /usr/local/www/crank]# wp --allow-root config create --dbname=crank --dbuser=crank --dbpassword=progress
    Error: Parameter errors:
     unknown --dbpassword parameter
    [root@www /usr/local/www/crank]# wp --allow-root config create --dbname=crank --dbuser=root                       
    Success: Generated 'wp-config.php' file.
    

    wp will create a wp-config.php file but a. it doesn’t ask for or accept a password and b. it allows you to create the file with root as the user with an empty password (or one read from the filesystem: can’t tell how it worked).

    I found the issue: localhost needed to be

    'localhost:/var/run/mysql/mysql.sock' not just localhost or even localhost:3306.

    I found it by comparing the other wp-config.php file.

    Thread Starter paul

    (@paul)

    Couple of small gotchas remain. Logging into two instances in different directories seems to confuse wordpress. If I log into the new one, it seems to refer me to the old subdirectory-based site. Could be an artifact of Safari’s password manager that doesn’t see different hosts or directories within a domain. But the datas I want seems to be there and exported to a WXR file. If it imports correctly, this will all have been worth it. From this experience, I can say that WXR looks like a much better way to back up wordpress installation than any mysql options.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘running multiple instances from one database? Possible?’ is closed to new replies.