经过检测mysql-proxy经常自动挂掉重启,已弃用。改用mycat了
在navicat客户端中登录mysql-proxy进行操作正常在laravel中执行任何sql语句都会报错
SQLSTATE[HY000]: General error: 1243 Unknown prepared statement handler (X) given to
mysqld_stmt_execute
以下为原问题
最近在做毕业设计项目。Mysql读写分离,主从复制。Mysql-proxy在A服务器,B服务器 Master负责写,C服务器 Slave负责读。在navicat客户端中登录mysql-proxy进行操作正常执行php artisan migrate抛出如下错误
PS C:\phpStudy\WWW\XXX\test> php artisan migrate
In Connection.php line 647:
SQLSTATE[HY000]: General error: 1243 Unknown prepared statement handler (2) given to
mysqld_stmt_execute (SQL: select * from information_schema.tables where table_schema =
shop and table_name = migrations)
In MySqlConnector.php line 57:
SQLSTATE[HY000]: General error: 1243 Unknown prepared statement handler (2) given to
mysqld_stmt_execute
百度了一下说是权限问题?我看了数据库information_schema中的表tables,确实没有table_schema = shop and table_name = migrations。这种怎么解决?Google没搜出来。*dzx是主从复制账户,proxy是读写分离的代理账户proxy配置如图---账户权限如图
4 回答
![?](http://img1.sycdn.imooc.com/5458626a0001503602200220-100-100.jpg)
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
其实laravel自带读写分离的配置.... 在数据库配置中,可以写一个: read配置和write配置.
'mysql' => [
'read' => [
'host' => '192.168.1.1',
//可以配置不同的账号密码端口
],
'write' => [
'host' => '196.168.1.2'
//可以配置不同的账号密码端口
],
'driver' => 'mysql',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
![?](http://img1.sycdn.imooc.com/545865890001495702200220-100-100.jpg)
慕桂英3389331
TA贡献2036条经验 获得超8个赞
我遇到了一样的问题,似乎mysql-proxy无法接受预处理语句
虽然题主已经改了,还是留下一个解决办法
在config/database.php中设置PDO模拟的预处理语句,然后发给mysql正常的sql
'options' =>[
PDO::ATTR_EMULATE_PREPARES => true,
],
经过简单测试,可以正常执行CURD操作
- 4 回答
- 0 关注
- 1239 浏览
添加回答
举报
0/150
提交
取消