[ERROR] MySQL Query Error: Can not connect to DB, bridge2cart for Veeqo prodcut managment

There are no errors on deployment. However my client requires the integration of Veeqo, a stock management software, that has an integration plugin for wordpress.

In the instructions here, I’ve completed both steps 9a and 9b.

Which state that I upload to the wordpress root, a folder, and set its permissions to 755 and 644 on the files it contains. But the above error is still present.

A test was done on a traditional server stack (one click install), which worked.

I’m guessing the error above is because bedrock’s file structure is different to a traditional wordpress architectur, and the bridge file is pointing to an incorrect directory.

Please help :worried:

The documentation at that link says you need 9a or 9b, not both. What happens if you only install the plug-in (and don’t have the “bridge file” stuff added via FTP). Do you get the same error?

Bedrock does use a specialized directory layout, but it conforms to everything WordPress requires and supports. Plugins that don’t work with it are generally at fault. See: https://roots.io/bedrock/docs/bedrock-compatibility/

1 Like

Thanks for the reply, that was a great idea, trying one after the other. @alwaysblank ++

I’ve looked into this bridge file, and have seen “M1_STORE_BASE_DIR” referenced in the url portion of the file like so:

include_once M1_STORE_BASE_DIR . 'includes/config.php';

So in the error message I’ve echoed out this var like so:
return '[ERROR] MySQL Query Error: Can not connect to DB <br/> ' . M1_STORE_BASE_DIR;

This prints out on the front end:

[ERROR] MySQL Query Error: Can not connect to DB
srv/www/my-website.com/releases/[date]/web/

This looks wrong to me. Any idea how to fix?

So I’ve ssh’d into the DO droplet, and ran the following command $ nano var/log/syslog.

There’s an error that keeps showing up, and I bet you it’s timestamp matches to every time bridge.php gets hit.

Jun 11 06:30:15 [prod-server] mysqld[30798]: 2019-06-11  6:30:15 139909839218432 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:30:16 [prod-server] mysqld[30798]: 2019-06-11  6:30:16 139909843977984 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:30:17 [prod-server] mysqld[30798]: 2019-06-11  6:30:17 139909843670784 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:34:26 [prod-server] mysqld[30798]: 2019-06-11  6:34:26 139909839218432 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:34:27 [prod-server] mysqld[30798]: 2019-06-11  6:34:27 139909843363584 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:34:28 [prod-server] mysqld[30798]: 2019-06-11  6:34:28 139909843977984 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:38:36 [prod-server] mysqld[30798]: 2019-06-11  6:38:36 139909843670784 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:38:37 [prod-server] mysqld[30798]: 2019-06-11  6:38:37 139909839218432 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Jun 11 06:38:38 [prod-server] mysqld[30798]: 2019-06-11  6:38:38 139909843363584 [Warning] Access denied for user 'root'@'localhost' (using password: NO)

I think the file is not getting the right credentials to connect with the DB. Probably because it dosn’t reference the vault file.

Or am I way off?

It does sound likes it’s having trouble connecting to your DB, but the include line you mention doesn’t sound like it’s trying to load a WordPress file: WP’s include folder is wp-includes, and the WP DB config isn’t I’m there anyway.

It doesn’t need to reference the vault file: the vault is only for Ansible when it deploys. Once deployed Bedrock uses the .env file generated by Ansible on the remote server to get things like DB connection credentials. It makes those available as constants for scripts loaded afterward (i.e. wp-config.php).

Without seeing the bridge script it’s hard to guess where the problem is. If Veeqo is a paid product they should offer support, so you should contact them.

1 Like

bridge script

I’ve been on IM for hours with their support, who’ve asked about adding the file to the nginx config.
The nginx error log on the DO droplet is empty tho.

How would I even go about adding it to the config? Is that a vagrant thing or Ansible also?

Once again, thank you for your support. It’s why I chose to use Roots in the first place.

It looks like this is the section where it’s trying to get WP DB connection info, and it does look like it’s making a lot of sketchy assumptions:


/**
 * Class M1_Config_Adapter_Wordpress
 */
class M1_Config_Adapter_Wordpress extends M1_Config_Adapter
{

  private $_multiSiteEnabled = false;
  /**
   * M1_Config_Adapter_Wordpress constructor.
   */
  public function __construct()
  {
    if (file_exists(M1_STORE_BASE_DIR . 'wp-config.php')) {
      $config = file_get_contents(M1_STORE_BASE_DIR . 'wp-config.php');
    } elseif (file_exists(realpath(M1_STORE_BASE_DIR . '..' . DIRECTORY_SEPARATOR . 'wp-config.php'))) {
      $config = file_get_contents(realpath(M1_STORE_BASE_DIR . '../wp-config.php'));
    } elseif (!$this->_tryLoadConfigs()) {
      die('ERROR_READING_STORE_CONFIG_FILE');
    }

    if (isset($config)) {
      $configs =  M1_Bridge::removeComments($config);
      $constants = M1_Bridge::parseDefinedConstants($configs, 'DB_NAME|DB_USER|DB_PASSWORD|DB_HOST|UPLOADS|WP_HOME|WP_SITEURL|WP_CONTENT_URL');
      $multiSiteSettings = M1_Bridge::parseDefinedConstants($configs, 'MULTISITE', false);

      preg_match('/\$table_prefix\s*=\s*[\'"](.*)[\'"]\s*;/', $config, $tblPrefixMatch);
      if (isset($constants['UPLOADS'])) {
        $this->imagesDir = preg_replace('/\'\.\'/', '', $constants['UPLOADS']);
      } else {
        $this->imagesDir = 'wp-content' . DIRECTORY_SEPARATOR . 'uploads';
      }

Have you tried the plug-in version if the bridge by itself? If it’s loaded as a plug-in it should have access to all of WP’s internals and would need to be making this guesses about where things are in the filesystem.

1 Like

Yes first try was with the plugin, and now I’ve done it by the deploy script, as in its on the repo. And made sure the permissions are correct.
Still no joy.

Their support is asking for me to whitelist an IP, would this be the problem? And how would I go about that?

That kind of depends on the specific request and how your server is configured. I’m not sure what whitelisting an IP would have to do with your problem, but that would probably be done either at the server level through whoever your host is, or by editing some server config files at a lower level (i.e. .htaccess if you’re on Apache).

Sorry about that, the server stack is: trellis, bedrock, sage 9. Sitting on digital ocean droplet.
I just followed this guide: https://roots.io/getting-started/docs/macos-basic-setup/

And this video:

So I’ve been reading this:

I’m not sure how to add it with ansible tho.

I found this: Enable remote access to DB to a specific IP using the ferm role

Added Veeqo’s IP to /trellis/group_vars/all/secruity.yml like so:

  - type: dport_accept
    dport: [http, https]
    filename: nginx_accept
  - type: dport_accept
    dport: [ssh]
    saddr: "{{ ip_whitelist }}"
  - type: dport_limit
    dport: [ssh]
    seconds: 300
    hits: 20
  - type: dport_accept
    dport: [mysql]
    saddr: "1.0.0.0.0" //not actual ip

What was the problem with your attempt in [ERROR] MySQL Query Error: Can not connect to DB, bridge2cart for Veeqo prodcut managment?

That looked correct to allow a specific IP to access the mysql port at least.

You can try just disabling ferm temporarily to confirm if it’s actually a firewall issue.

https://www.poftut.com/how-to-start-stop-and-enable-disable-iptables-or-ufw-in-ubuntu-debian-kali-mint/

1 Like

@ShaunMac what mysql version are you running? mysql --version

if it’s 8.0.16, I think I know what might be going on…

something about php/mysqli does not natively support an updated authentication strategy… I ran into similar issue with a new local install of WP… This fixed it for me:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{yourPW}';

1 Like

I think that was a red herring, a rabbit hole, a waist of time.

How do I get .env variables to work inside this plugin?
I’ve tried this:

define('DB_NAME', getenv(DB_NAME')); // doesn't work

I’ve tried this https://github.com/vlucas/phpdotenv:

Env::init();

$dotenv = Dotenv\Dotenv::create($root_dir);
if (file_exists($root_dir . '/.env')) {
    $dotenv->load();
    $dotenv->required(['WP_HOME', 'WP_SITEURL']);
    if (!env('DATABASE_URL')) {
        $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']);
    }
}

Nope not that ether.

I’m starting to think it’s just me, and I should just give up and go do something rewarding.

This topic was automatically closed after 42 days. New replies are no longer allowed.