LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2023, 07:18 AM   #1
Al99
LQ Newbie
 
Registered: Nov 2020
Posts: 22

Rep: Reputation: Disabled
Problem connecting to mysql database with mysql workbench


Hi I posted this on mysql forums but nobody replied so I wonder if someone could help me here? I am new to mysql and I want to learn some code. I installed mysql community workbench on linux mint victoria with snapd and then I installed mysql client and server with the software centre. I can see a database in mysql workbench : Local instance 3306 : root : localhost:3306. When I click on it I get the following message:

Your connection attempt failed for user 'root' to the Mysql server at localhost:3306:

Access denied for user 'root'@'localhost'

Please:
1 Check that Mysql is running on address localhost
2 Check that Mysql is reachable on port 3306(note: 3306 is the default, but this can be changed)
3 Check the user 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 are connecting from

Can someone show me how to carry out these checks so I can connect to the database and practice some code?

Thanks.
 
Old 12-14-2023, 07:43 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Al99 View Post
Hi I posted this on mysql forums but nobody replied so I wonder if someone could help me here? I am new to mysql and I want to learn some code. I installed mysql community workbench on linux mint victoria with snapd and then I installed mysql client and server with the software centre. I can see a database in mysql workbench : Local instance 3306 : root : localhost:3306. When I click on it I get the following message:
Code:
Your connection attempt failed for user 'root' to the Mysql server at localhost:3306:

Access denied for user 'root'@'localhost'

Please:
1 Check that Mysql is running on address localhost
2 Check that Mysql is reachable on port 3306(note: 3306 is the default, but this can be changed)
3 Check the user 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 are connecting from
Can someone show me how to carry out these checks so I can connect to the database and practice some code?
Did you try to look up how to do any of this??? Doing basic research should be something done for any issue.

MySQL is just another Linux service. Try running "sudo systemctl status mysql.service" and see if it's running. Did you actually modify the MySQL config to change the port?? If not, then it's still using 3306. And root should (by default) have access to things (again, unless you've changed things).
 
Old 12-14-2023, 10:49 AM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,523

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
Which distribution of Linux are you using and which version?
I would suggest running mysql_secure_installation explained at the link below. Did you use a password when trying to access mysql? Did you create a password for root in mysql?

https://dev.mysql.com/doc/refman/8.0...tallation.html
 
Old 12-14-2023, 09:17 PM   #4
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 779

Rep: Reputation: 246Reputation: 246Reputation: 246
See if the process is running:
Code:
ss -l -p -n | grep mysql                                                                                                      
u_str LISTEN 0      80             /var/run/mysql/mysql.sock 8375                   * 0    users:(("mariadbd",pid=1492,fd=24))
Note that there's a "skip-networking" parameter. Make sure the server's not started with that if you want to connect over a network. Check its config files. Try to access the server through the command line first to make sure it works. Also check ~/.my.cnf config files. If you don't have a .my.cnf, you can specify the user and pass like mysql -u root -p.

Code:
mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.11.6-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.023 sec)

MariaDB [(none)]> \q
Bye
 
Old 12-15-2023, 08:58 AM   #5
Al99
LQ Newbie
 
Registered: Nov 2020
Posts: 22

Original Poster
Rep: Reputation: Disabled
Problem logging in

when I try to log in in the terminal with mysql -u root -p
I get ERROR 1698 (28000): Access denied for user 'root'@'localhost'
how do I correct that please?
 
Old 12-15-2023, 09:11 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,715

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
I would guess that you never set a password or changed the authentication method for root.

https://phoenixnap.com/kb/access-den...root-localhost
 
Old 12-15-2023, 09:18 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Al99 View Post
when I try to log in in the terminal with mysql -u root -p
I get ERROR 1698 (28000): Access denied for user 'root'@'localhost'
how do I correct that please?
As you were told, you should already have access. You were told how to check to see if the service is running, but you haven't actually told us if you DID anything yet, aside from the same thing you did initially; try to log in.

Did you check the service to see if it's running??? Did you change anything?? Did you try the command given to you by jaywa? Did you try to look up the exact message you got, that michaelk gave you a link for???
 
Old 12-15-2023, 11:04 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Al99 View Post
4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you are connecting from
By default newer installs of MySQL set a random password that you can retrieve by doing grep ‘temporary’ on the mysql log file then you can set the root password with:

Code:
mysql -uroot -pWhateverYouFound

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd';
flush privileges;
exit;
 
1 members found this post helpful.
Old 12-15-2023, 11:11 AM   #9
Al99
LQ Newbie
 
Registered: Nov 2020
Posts: 22

Original Poster
Rep: Reputation: Disabled
I tried this and I think its working now.

Thanks for all your help! :-)

https://www.databasestar.com/access-...-at-localhost/
 
Old 12-15-2023, 12:05 PM   #10
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,523

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
If you had run mysql_secure_installation as suggested above, this would all have been taken care of as you are then asked to create a root password for mysql if you don't have one.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Resolve Cannot Connect to Database Server (MySQL Workbench) LXer Syndicated Linux News 0 05-17-2023 04:54 PM
LXer: How to Install and Use MySQL Workbench As Your Database GUI LXer Syndicated Linux News 0 04-16-2017 07:38 PM
problem trying to build mysql-workbench-gpl on -current (14) gtludwig Slackware 9 07-05-2012 12:50 PM
MySql - mysql-workbench problem tamtam Slackware 1 07-27-2010 11:52 AM
LXer: Visual MySQL Database Design in MySQL Workbench LXer Syndicated Linux News 0 06-12-2008 07:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration