MySQL适用于终端但不适用于PHP

时间:2017-03-29 15:50:33

标签: php mysql amazon-web-services mysqli centos

我已将我的项目从AWS迁移到Google Cloud。我之前有一个工作应用程序,但现在迁移到GCP后, mysqli_connect 似乎不再起作用。 到目前为止,我已经安装了以下内容:

  1. PHP-MySQL的-5.4.16-42.el7.x86_64
  2. PHP-PDO-5.4.16-42.el7.x86_64
  3. PHP-5.4.16-42.el7.x86_64
  4. php-common-5.4.16-42.el7.x86_64
  5. PHP-CLI-5.4.16-42.el7.x86_64
  6. MariaDB的-库-5.5.52-1.el7.x86_64
  7. MariaDB的-5.5.52-1.el7.x86_64
  8. 我可以使用终端访问MySQL但无法使用PHP连接到远程数据库(在AWS RDS上)。 RDS数据库对IP连接没有任何限制,并向全世界开放。我已经尝试完全删除PHP,MySQL,MariaDB,但是没有成功。迁移后,连接到数据库的脚本保持不变。其他功能,如 mysqli_fetch_assoc mysqli_query 不会引发任何错误。以下是 mysqld_log

    的内容
    170329 07:20:15 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
    170329 07:31:09 mysqld_safe Logging to '/var/log/mysqld.log'.
    170329 07:31:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    2017-03-29 07:31:09 0 [Warning] s deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2017-03-29 07:31:09 0 [Note] /usr/sbin/mysqld (mysqld 5.6.35) starting as process 32611 ...
    2017-03-29 07:31:09 32611 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
    
    2017-03-29 07:31:09 32611 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
    
    2017-03-29 07:31:09 32611 [Note] Plugin 'FEDERATED' is disabled.
    2017-03-29 07:31:09 32611 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2017-03-29 07:31:09 32611 [Note] InnoDB: The InnoDB memory heap is disabled
    2017-03-29 07:31:09 32611 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2017-03-29 07:31:09 32611 [Note] InnoDB: Memory barrier is not used
    2017-03-29 07:31:09 32611 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2017-03-29 07:31:09 32611 [Note] InnoDB: Using Linux native AIO
    2017-03-29 07:31:09 32611 [Note] InnoDB: Using CPU crc32 instructions
    2017-03-29 07:31:09 32611 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2017-03-29 07:31:09 32611 [Note] InnoDB: Completed initialization of buffer pool
    2017-03-29 07:31:09 32611 [Note] InnoDB: Highest supported file format is Barracuda.
    2017-03-29 07:31:09 32611 [Note] InnoDB: 128 rollback segment(s) are active.
    2017-03-29 07:31:09 32611 [Note] InnoDB: Waiting for purge to start
    2017-03-29 07:31:09 32611 [Note] InnoDB: 5.6.35 started; log sequence number 1626037
    2017-03-29 07:31:09 32611 [Note] Server hostname (bind-address): '*'; port: 3306
    2017-03-29 07:31:09 32611 [Note] IPv6 is available.
    2017-03-29 07:31:09 32611 [Note]   - '::' resolves to '::';
    2017-03-29 07:31:09 32611 [Note] Server socket created on IP: '::'.
    2017-03-29 07:31:09 32611 [Note] Event Scheduler: Loaded 0 events
    2017-03-29 07:31:09 32611 [Note] /usr/sbin/mysqld: ready for connections.
    Version: '5.6.35'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
    

1 个答案:

答案 0 :(得分:0)

你写的是你使用了mysqli_connect,但是你已经安装了php-mysql-5.4.16-42.el7.x86_64(注意:没有' i')。您需要mysqli的包才能连接PHP。