duankuai6586 2014-11-24 18:35
浏览 217

如何在Laravel中使用远程数据库

I'm trying to upload an application Laravel to an FTP server, the application already works but the database does not, is that the database is mounted on another server, and I use ping and working properly, I hope your help, thanks in advance.

This my file configuration:

    'mysql' => array(
        'driver'    => 'mysql',
        'host'      => '198.168.169.151',
        'port' => '2222',
        'database'  => 'Radec_Apps',
        'username'  => 'radec_user',
        'password'  => 'Mkn!',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

I need to configure something else?

  • 写回答

1条回答 默认 最新

  • duandao2083 2014-11-24 19:02
    关注

    Granting Access

    Granting access to a user from a remote host is fairly simple and can be accomplished from just a few steps. First you will need to login to your MySQL server as the root user. You can do this by typing the following command:

    mysql -u root -p

    This will prompt you for your MySQL root password.

    Once you are logged into MySQL you need to issue the GRANT command that will enable access for your remote user. In this example we will be creating a brand new user (fooUser) that will have full access to the fooDatabase database.

    Keep in mind that this statement is not complete and will need some items changed. Please change 1.2.3.4 to the IP address that we obtained above. You will also need to change my_password with the password that you would like to use for fooUser.

    mysql> GRANT ALL ON fooDatabase.* TO fooUser@'1.2.3.4' IDENTIFIED BY 'my_password';

    This statement will grant ALL permissions to the newly created user fooUser with a password of 'my_password' when they connect from the IP address 1.2.3.4.

    Testing Remotely

    Now you can test your connection remotely. You can access your MySQL server from another Linux server:

    mysql -u fooUser -p -h 44.55.66.77

    Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 5.0.45 Source distribution

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> _

    Note that the IP of our MySQL server is 44.55.66.77 in this example.

    @ref: http://www.rackspace.com/knowledge_center/article/mysql-connect-to-your-database-remotely

    you may need to change the my.cnf to change the BIND ip address.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)