Should I use root to start my website?

Posted January 23, 2015 3.4k views


I’m in the process of learning how to use VPS to host my website. I have created LAMP stack and phpmyadmin and have my code ready. Aside from that, I haven’t created any additional users or set any additional security checkpoints yet.

I just wonder, is it ok to start my website, by using this “root” to upload all the file to the “/var/www/” folder and keep moving on from this? Or should I create another user?

Thank you so much!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Your server works from www-data user (by default) and this user will not be able to access root’s files, so create new user (for example ’myuser’) and add myuser to www-data usergroup. Anyway You shouldn’t use root access as default.

  • thank you. i did create newuser and add it to www-data, set the www folder to www-date owned, but somehow when i run the the connection to the sql, i get the problem :

    “Access denied for user ‘root’@'localhost’ (using password: NO)”

    Is it because of my code or because of my setup? Sorry i’m kinda new to this.

  • @PeterBerk nope, it’s not tied to the distribution rights to the operating system, but due to the settings of your MySQL server. Most likely during the installation MySQL you change the default password (no password) on some kind of a. Now you need to specify the new password in the configuration file in your script.

  • @PeterBerk: The operating system’s root user and MySQL’s root user are entirely separate. The OS’s root user has access to everything on the droplet, while the MySQL root user has access to everything in MySQL. You can connect to MySQL as the root (MySQL) user from any user, including www-data.

    Access denied for user ‘root’@'localhost’ (using password: NO)

    The MySQL root user usually has a password, so try specifying that. If you do not know what it is, you can either look for it in /root/.my.cnf if it exists, or reset it: