0

I just installed mysql-server and set the root password. I can log in to it from the terminal, but only with sudo:

jack@Ubuntu-Tower:~$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
jack@Ubuntu-Tower:~$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.

I can't connect to this server through MySQL Workbench (127.0.0.1, port 3306, username root, and the correct password of course). The reason I'm asking this on an Ubuntu forum is because of the issue with sudo... is that normal? Could it be related to my Workbench problem?

2

The reason I'm asking this on an Ubuntu forum is because of the issue with sudo... is that normal?

Yes. We take security serious ;)

Could it be related to my Workbench problem?

Well it gets to the underlying problem:

You need to grant privileges for workbench to connect to the database. Generic rule is:

GRANT ALL PRIVILEGES ON database.table TO 'user'@'localhost';
FLUSH PRIVILEGES;

where

  • database
  • table
  • user
  • localhost (this can be the IP address of the system using workbenech if not on the same system)

need to be adjusted to your needs and you can use * as a wildcard.

You can use

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

to create a user where user, localhost and password need to be changed to your situation. From a security point of view leave "root" as is and use a username that is specific to your situation.

  • I created a database called dev and ran GRANT ALL PRIVILEGES ON dev.* TO 'root'@'localhost'; (and flushed privileges), but I still can't log in without sudo. Did I do something wrong? – Jack M Apr 26 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.