I just installed Ubuntu 16.04 and installed web server on it. Everything works well, but I cannot access database. Even if I create new user and grant all privileges, I can\
Just Create New User for MySQL do not use root. there is a problem its security issue
sudo mysql -p -u root
Login into MySQL or MariaDB with root privileges
CREATE USER 'troy121'@'%' IDENTIFIED BY 'mypassword123';
login and create a new user
GRANT ALL PRIVILEGES ON *.* TO 'magento121121'@'%' WITH GRANT OPTION;
and grant privileges to access "." and "@" "%" any location not just only 'localhost'
exit;
if you want to see your privilege table SHOW GRANTS;
& Enjoy.