What to do after upload of a db on a server

Hi! I’ve been developing a website with a MySQL database locally. This week I will have to put it online. Since it’s the first time that I do this, can you tell me everything I have to pay attention to?

For example, how should I change this line of code?

$conn = mysqli_connect('localhost', 'root', 'root', 'db');

And all this kind of stuff ^^

Thank you very much in advance for your answers :slight_smile:

You will need to change that to match the database details of your live webserver, the easiest way to export and upload a database is to use the mysql_dump program to generate yourself a .sql file, upload this via FTP and use the command line mysql client to import it (\. file.sql)

Should I change the database password? And should I leave the user as root?

you should change all of the details to those specific for your live server.

I certainly wouldn’t suggest running as root in production, you will want to use a more restricted user.

I’m sorry for the stupid question, but if I need users to edit the database contents, shouldn’t I use a root user?

You create a more restricted user that can still edit the contents… teh root (super user) should have access to everything, but shouldn’t be used for general day to day running.

What can a root user do that a user that is able to edit the contents can’t?

The root user can do anything to ANY database.

A normal user you would limit to only the databases that user should be able to work with. It gives you the power to separate site A from site B so there is no way data can be accessed by the wrong system / user.