I can't access my MySQL MariaDB database

I'm on Linux Deepin 15.19 and installed for Web development, however when I can not create new databases by MySQL Worckbench by says:

Your connection attempt failed for user 'root' from your host to server at localhost: 3306: Access denied for user 'root' @ 'localhost'

Please: 1 Check that mysql is running on server localhost 2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed) 3 Check The root has rights to connect to localhost from your address (mysql rights define what clients can connect to the server and from which machines) 4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you're connecting from

I already tried to uninstall, I did everything. I tried to change the password by the command

sudo mysql -u root 

And right after

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';

And that doesn't even solve it, what I have is error.

ERROR 1064 (42000): you have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USER ' root'@ 'localhost' IDENTIFIED WITH mysql_native_password BY '1234" at line 1

I am very much in need of your help because my development depends on it.

Author: Mateus Cazuza, 2019-05-05

2 answers

Well, from the messages it seems to be a problem with the user and password, I saw that this distro is based on debian so I think it's the same:

1-stop mysql process:

sudo /etc/init.d/mysql stop

2-Restart the mysql process, not checking the permissions of the tables:

sudo /usr/sbin/mysqld --skip-grant-tables &

3-access MySQL client

 mysql -u root

4-run the command below to be able to change any password:

FLUSH PRIVILEGES;

5-then change the root password

SET PASSWORD FOR root@'localhost' = PASSWORD('senha');

6-update the privileges:

FLUSH PRIVILEGES;

Restarts mysql in default mode:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

Commands removed and adapted from https://help.ubuntu.com/community/MysqlPasswordReset

 2
Author: rnd_rss, 2019-05-05 13:17:50

Tries to open your terminal and use the command

mysql -u root -p

This command will prompt for your mysql password after typing must access mysql from the terminal. If you normally access the error is in some configuration of your workbench. If you do not access normally the error is in the installation of your mysql try to uninstall and install again and perform the same test again and make sure you enter the password correctly.

 0
Author: Thales Morais, 2019-05-05 13:38:17