Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adrielzxdf's avatar

Laravel Forge Limited Database Access

Hi Laracasts,

I have a few sites on Forge's server and I would like to give database access to one of the site. However, in order to access the database, it would require access to the server where all the databases will be accessible. How can I limit the access to only one database?

0 likes
7 replies
richard@gorbutt.com's avatar

What I do when I provision a server is to login using SequelPro(mac) and create whatever database(s) I need, then I usually create a new user with only those rights to the database it needs (one user per database).

Sure many ways to do.

2 likes
willvincent's avatar
Level 54

GRANT [privileges] ON [database].* TO [username][@[host]] IDENTIFIED BY '[password]'

Where;

  • [privileges] is ALL or a comma delimited combination of available privileges. Best practices would dictate that you only grant the necessary permissions to your DB user(s).
  • [database] is the name of the DB
  • [username] is the username that will be used to connect. host is optional but would allow you to restrict connections for this user to only originating from specific IP addresses.
  • [password] is the password used to connect

instead of db.* you could also grant privileges to only specific tables of a DB.. though that's probably largely useless for most use cases.

2 likes
adrielzxdf's avatar

Thanks guys, I wasn't aware of MySQL user grants.

BobGann's avatar

I see this is quite old - but I'm facing the same problem. I need to create a user for Mysql to a Forge managed database that is a read-only user. I can create users in Forge, but they appear to have all permission which I cannot have. I can connect to the database from a management tool (I use navicat) and open a console, but I cannot use "Create USER ' to create a user (the forge user does not seem to have permissions). Nor can I seem to use Grant to give limited (select) access to the user I created in Forge. I try to use GRANT [privileges] and so on and I get an SQL error near IDENTIFIED BY. Any suggestions?

1 like
gelin28's avatar

@bobgann you have to install phpmyadmin for your case, login with user with higher privilege and remove or add permissions needed for user separately.

Please or to participate in this conversation.