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

Melodia's avatar

How can I access my database

I am deploying a Laravel site for the first time but I have a few issues:

How can I access my database tables? For example when I register a user, I want to change his access rights to admin, but now, without using phpmyadmin I got confused?

Is there a way I can export content to the database?

Ultimately, when I created my server, it gave an IP address and there I have my default site. The domain was registered at 1-grid and the site being hosted by Digital Ocean. How can I hook up my domain to th IP address generated by forge?

I created an A record at digital ocean with mydomain.com and pointed to my new server 127.1.2.5, but this does not seem to be the right answer.

Hope someone can guide.

0 likes
9 replies
Cronix's avatar

How can I access my database tables? For example when I register a user, I want to change his access rights to admin, but now, without using phpmyadmin I got confused?

Wouldn't you have an admin panel or something where admin can change that using a form? You shouldn't be using phpmyadmin or similar for stuff like that.

Is there a way I can export content to the database?

Sure, look into mysqldump. Basically backup your current database and import it to the forge database.

I created an A record at digital ocean with mydomain.com and pointed to my new server 127.1.2.5, but this does not seem to be the right answer.

I doubt that is the right IP for your server. 127.x.x.x isn't publicly accessible. It's a loopback address, which would only be able to be accessed from the host itself. That refers to the local machine itself and not routeable via the internet.

1 like
jlrdw's avatar

How can I access my database tables?

How did you access them (practice this stuff) in development? It will be similar.

Also Digital Ocean has tutorials on their site on setting up and getting all working.

Melodia's avatar

"Wouldn't you have an admin panel or something where admin can change that using a form? You shouldn't be using phpmyadmin or similar for stuff like that."

Yes I do have an admin panel. But it happens that when I uploaded the site to forge for the first, I had an empty database, so I had to create a user and make it admin. What I did is: I disabled the email verification and automatically assigned an admin. Then I rolled back to how it was and put my RegistrationController in the gitignore. But would there be a better better approach than that?

"Sure, look into mysqldump. Basically backup your current database and import it to the forge database."

Perfect, Will look into that.

"I doubt that is the right IP for your server. 127.x.x.x isn't publicly accessible. It's a loopback address, which would only be able to be accessed from the host itself. That refers to the local machine itself and not routeable via the internet."

That IP number is just an example.

Cronix's avatar
Cronix
Best Answer
Level 67

Yes I do have an admin panel. But it happens that when I uploaded the site to forge for the first, I had an empty database, so I had to create a user and make it admin. What I did is: I disabled the email verification and automatically assigned an admin. Then I rolled back to how it was and put my RegistrationController in the gitignore. But would there be a better better approach than that?

You can always use a database seed and create your initial user. https://laravel.com/docs/5.7/seeding

Or (my preference for production data) just create a migration to make the user, and instead of creating a db table you just create the user using DB::table('users')->insert($arrayOfUserData).

Or, you could import the data as I mentioned with mysqldump.

I like the migration method as it will only ever run once, whereas the seed will run everytime you tell it to seed the db. I only use seeds to create fake data, for testing. Not actual production data.

1 like
Melodia's avatar

I will go for the migration method because as you mentioned seed is not production.

Melodia's avatar

My only issue now is with Forge and the hosting

Cronix's avatar

In the top of the forge control panel when you're viewing the server, it should show 2 ips for the server at the top of the screen. One is public, and the other is private. The private ip is in parenthesis - don't use that one. Use the public IP.

You just need an A record for the domain name that points to the public IP of the server.

You said you registered the domain name through 1-grid. That's probably where you need to set the record, not on Digital Ocean unless you've transferred DNS services to DO. I've never used them, so can't help with that part. Also, depending on the dns provider, it can take up to 48 hours for it to become "live". I use AWS Route53 for DNS, and they usually only take a few minutes before you can access it via the domain name.

Melodia's avatar

So I dont add any A record to the Digital Ocean? And when I point the A record to the public IP given by forge, which is server name do I use? I only see the one given by forge: quaint_name, but that doesnt seem to be the right server name. I was trying to test now with my GoDaddy account

Cronix's avatar

So I dont add any A record to the Digital Ocean?

Only if you transferred DNS services to Digital Ocean. Most likely, you didn't do this. Check with your registrar (1-grid) if you're not sure if you did or not. Most likely, you'd set it in 1-grids control panel.

which is server name do I use?

Not server name, domain name, ie xyz.com - your site.

Did you create a site on Forge for the domain (xyz.com)? Don't set it up as the default site. That's what responds when you visit the ip instead of an actual domain name.

I'd watch this laracasts series on Forge. It might be easier to learn this from. https://laracasts.com/series/learn-laravel-forge

Please or to participate in this conversation.