motomedialab/maxscale-connector 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

motomedialab/maxscale-connector

Composer 安装命令:

composer require motomedialab/maxscale-connector

包简介

Fixes database connection errors when routing Laravel database connections via MariaDB MaxScale

README 文档

README

A simple package designed to provide a fix for the existing Illuminate\Database\Connectors\MySQLConnector class.

When connecting to MaxScale using Laravel, the $connection->exec("use {$config['database']};"); command is run, not only creating a surplus query but also triggering a database connection error when using MariaDB MaxScale. Within MaxScale logs, you'll see an error similar to:

error  : (1) Invalid authentication message from backend 'your-backend'. Error code: 1044, Msg : #42000: Access denied for user 'username'@'%' to database '`database_name`'

The reason for this, is that Laravel is trying to establish a connection with '`database_name`' (backticks) when it should simply be connecting to 'database_name' (no backticks).

As the database name has already been declared within the PDO DSN (see PR #34389), the offending line of code is effectively surplus to requirements already. All this package does is remove the surplus database selection by overriding the existing MySQL connector to remove the offending lines of code.

Installation

Install via composer composer require motomedialab/maxscale-connector

Within your config/database.php you have two options:

  1. Update your database.connections.mysql.driver config flag to maxscale

  2. Create a new configuration for MaxScale

    1. Copy the entire database.connections.mysql config array
    2. Rename the key to maxscale
    3. Change the driver flag database.connections.maxscale.driver to maxscale
    4. Update your .env file to reflect this change, e.g. DB_CONNECTION=maxscale

Once one of the above options have been completed, you should be able to connect to your MaxScale instance via Laravel no problem.

Notes

  • While this package was built to resolve Laravel MaxScale issues, the package will still work with MySQL and remove the surplus query being performed on each load

统计信息

  • 总下载量: 594
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固