【问题标题】:Migrating existing cakephp 3.0 database to postgres from mysql将现有 cakephp 3.0 数据库从 mysql 迁移到 postgres
【发布时间】:2016-02-29 11:38:53
【问题描述】:

我正在将 cakephp 3.0 数据库从 mysql 迁移到 postgress。我使用this 工具进行数据库迁移,效果很好。之后我更改了配置文件,如下所示。

  'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Postgres',
            'persistent' => false,
            'host' => 'localhost',
            'port' => '5432',
            'username' => 'postgres',
            'password' => 'mypass',
            'database' => 'cake_bookmarks',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'cacheMetadata' => true,
            'log' => false,
            'quoteIdentifiers' => false,

            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
        ],

localhost 中的根文件夹也显示“已成功连接到数据库”。但是,当我运行我的应用程序时,它会显示错误:

无法描述 mytable。它有 0 列。蛋糕\数据库\异常

我无法确定这是因为没有连接到数据库(我认为这不太可能,因为根页面显示为已连接)或 cakephp 无法使用我的数据库。 如果是这样,我该如何解决这个问题。我对 cakephp 也很陌生,只是配置和做一些基本的事情。

【问题讨论】:

  • 能否添加您使用的 CakePHP 版本?
  • 3,0 ,我会更新问题
  • 您的数据库中似乎没有该表。我建议检查该表是否存在,数据库用户是否具有读取它的权限,并且您在数组中配置了正确的架构。

标签: php mysql database postgresql cakephp


【解决方案1】:

尝试以下(每一步后测试):

  • 检查表是否存在于数据库中
  • 检查表中是否定义了预期的列
  • 清除Cake缓存(如果FileCache足够删除tmp/cache/persistenttmp/cache/modelstmp/cache/views下的文件
  • 检查特定用户对数据库cake_bookmarks的权限(可能通过phppgadmin)

希望能提供帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-02
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-13
    相关资源
    最近更新 更多