1

Here's the scenario:

I created a MySQL database on CPanel using CPanel's helper tool, also created a user for this database, and i run queries on this database using phpMyAdmin (which i also access through CPanel).

I'm developing a Laravel application using the PhpStorm IDE, and i need to connect the application to this remote database. My doubt is, which credentials should i put on .env file?

On the main page of phpMyAdmin, it says:

 Server: Localhost via UNIX socket
 Server Type: MySQL
 Server Connection: SSL is not being used

plus, the 'host:port' shows up as localhost:3306.

I already tried to use the 'host:port' credentials of my CPanel account, the localhost:3306, the user/password of my CPanel account, and the user/password created for the database (and all the combinations between these four credentials, plus using the database name) and nothing worked. I'm testing the connection on the PhpStorm's 'Add Database' section, here. If it connects, I'll know which are the right credentials. So far, i've only got "Access denied" error (example).

Am I looking at the right things? Or the only way to connect is using this SSL connection? (and if so, is there a tutorial on how to do this?)

Other suggestions on how to work on this scenario are welcome too :)

Gabriel
  • 21
  • 3
  • 1
    **1.** How "remote" is your CPanel and web server? Is there an option to create another user for the DB using CPanel helper tool? **2.** The "Access denied for `'user'@'localhost'`" looks like a typical mysql config error - try applying solutions shared here, e.g. https://stackoverflow.com/a/41793945/8020009 – Dmitrii May 26 '21 at 09:46
  • In that CPanel account i can manage domains/subdomains, databases, access file directories, etc., and i also can create another DB users. I will take a look at the solutions you sended. Thanks! – Gabriel May 26 '21 at 13:37

2 Answers2

4

If you are developing locally, you don't want to connect to a remote database. Just set up a local DB to develop with.

damask
  • 529
  • 4
  • 17
  • I'm not developing locally (sorry for don't point that before). First I'm developing on localhost (XAMPP), but right after I finish some functionality, I upload the files to the server, which already has a defined subdomain for that application. So, I wanted to set the DB connection since now. – Gabriel May 26 '21 at 13:53
1

Just found the answer. The connection worked using the CPanel credentials (mycpanelhost.com:3306, CPanel login, CPanel password, DB name). Thing is, I didn't notice a section on CPanel called 'Remote MySQL', where I should put my IP address to allow the connection to the remote database.

Lack of attention from my part :p. Anyway, much thanks for everyone who spend some time answering!

Gabriel
  • 21
  • 3