I have created a droplet with digitalocean and installed mariadb
using the apt install mariadb-server
command. Now I want to connect to my server using php
and I use this:
mysqli_connect('localhost', 'root', '');
The problem is I always have Access denied for user 'root'@'localhost'
error. I don't understand why this happens. I can login using mysql -uroot
when I am logged into my server. Also when I create a new user using
CREATE USER 'test'@'localhost' IDENTIFIED BY 'test';
GRANT ALL ON *.* TO 'test'@'localhost';
I can connect using php mysqli_connect
. What am I doing wrong? Why can't I connect with root
?