Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (5k points)

I installed a web server on Ubuntu 16.04. It worked fine, but I am unable to access the database. If I create a new user and grant all privileges, I can't create database In PHP I'm getting the following error:

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

Phpmyadmin is not working. 

PHP Code:

protected $host = '';

protected $db = 'dbname';

protected $name = 'root';

protected $pass = 'root';

protected $conn;

private static $settings = array(



public function __construct() {

    try {

        $this->conn = new PDO("mysql:host=$this->host;dbname=$this->db", $this->name, $this->pass, self::$settings);

    } catch (PDOException $e) {

        echo $e->getMessage();



1 Answer

0 votes
by (10.2k points)

It is pretty simple that you cannot use root user in 5.7 anymore without becoming a sudoer. This signifies that you cannot run mysql -u root anymore and have to do sudo mysql -u root instead.

It also signifies that it won't work if you're using the root user in a GUI. To run it you need to create a new user with the required privileges and use that instead.

If you want to get more insights into SQL, check out this SQL Course from Intellipaat.

Browse Categories