0

I have a MySQL server running on ubuntu server. I've been connecting remotely to it with mysql workbench for months. I recently rebooted my Ubuntu server and afterwards I am now unable to connect remotely to the MySQL database with MySQL workbench. I can still login locally to the MySQL database with the same user once I've ssh in to the Ubuntu server. I'm trying to follow the trouble shooting steps in the link below. Does anyone see what the issue might be?

following steps here:

https://devanswers.co/cant-connect-mysql-server-remotely/

Port Scanning host: xxxxxxxx

     Open TCP Port:     3306        mysql
Port Scan has completed…

looks like the firewall already had rules for mysql

sudo ufw status
[sudo] password for scotsditch: 
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
3306                       ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
3306 (v6)                  ALLOW       Anywhere (v6) 

not finding bind-address

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf


# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log

update:

MySQL Workbench error:

Your connection attempt failed for user 'user' to the MySQL server at xxx.xxx.xx.xxx:3306:
  Access denied for user 'user'@'%%' (using password: YES)

Please:
1 Check that MySQL is running on address xxx.xxx.xx.xxx
2 Check that MySQL is reachable on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the user user has rights to connect to xxx.xxx.xx.xxx 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 xxx.xxx.xx.xxx connecting from the host address you're connecting from

update:

sudo mysqldump --all-databases > dump_042021.sql

mysqldump: Error: 'The user specified as a definer ('mysql.infoschema'@'localhost') does not exist' when trying to dump tablespaces
mysqldump: Couldn't execute 'SHOW DATABASES': The user specified as a definer ('mysql.infoschema'@'localhost') does not exist (1449)

update:

sudo mysqld --upgrade=FORCE

2021-04-21T15:25:00.312253Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 10803
2021-04-21T15:25:00.313486Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2021-04-21T15:25:00.313520Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-21T15:25:00.313620Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23)  MySQL Community Server - GPL.

update:

select host,user,grant_priv,super_priv from mysql.user;

+-----------+------------------+------------+------------+
| host      | user             | grant_priv | super_priv |
+-----------+------------------+------------+------------+
| localhost | root             | Y          | Y          |
| localhost | mysql.session    | N          | Y          |
| localhost | mysql.sys        | N          | N          |
| localhost | debian-sys-maint | Y          | Y          |
| %         | user2            | N          | N          |
| %         | user1            | N          | N          |
| 0.0.0.0   | user1            | N          | N          |
| %         | user3            | N          | N          |
+-----------+------------------+------------+------------+



mysqldump -u user1 -p --all-databases > dump_042121.sql

Enter password: 
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
mysqldump: Couldn't execute 'SHOW DATABASES': Access denied for user 'user1'@'%' (using password: YES) (1045)
vitaliis
  • 4,082
  • 5
  • 18
  • 40
user3476463
  • 3,967
  • 22
  • 57
  • 117
  • Does MySQL Workbench display any error when you try to test the connection? – Bill Karwin Apr 20 '21 at 15:27
  • @BillKarwin thank you for getting back to me on this. I've added an update with the error I'm getting when trying to connect with the 'user' with mysql workbench. I'm able to ssh in with this user and then login to mysql and query the db no problem. It seems to just be an issue when remote connecting, and just since the ubuntu reboot. – user3476463 Apr 21 '21 at 00:09
  • 1
    Well the error message shows that it is reaching MySQL Server (no firewalls blocking it) but it could not authenticate the user & password you provided. Note that in MySQL, a user accessing from localhost (like when you ssh to the server) is not the same as the user accessing from a remote host. They may have different passwords and different privileges. – Bill Karwin Apr 21 '21 at 00:16
  • @BillKarwin I tried backing up my databases mysqldump but got an error. I added it above as an update. I googled the error and found an SO post that seems related: https://stackoverflow.com/questions/49992868/mysql-errorthe-user-specified-as-a-definer-mysql-infoschemalocalhost-doe I did previously upgrade mysql version, could that be the issue? if so, do I need to run the docker related command mentioned in the post "docker exec -it mysql bash" ? I'm unaware that I might be running mysql off a docker image, I just installed it on my ubuntu server. – user3476463 Apr 21 '21 at 06:27
  • "I did previously upgrade mysql version" Please add info from which version to which version you did do an upgrade. If you upgraded to 8.0+, see: [Mysql 8 remote access](https://stackoverflow.com/questions/50570592/mysql-8-remote-access) – Luuk Apr 21 '21 at 06:33
  • Also (if more info is needed): https://serverfault.com/questions/139323/how-to-bind-mysql-server-to-more-than-one-ip-address – Luuk Apr 21 '21 at 06:39
  • @Luuk I tried adding the bind-address =0.0.0.0 and restarting mysql, didn't solve the remote connection issue. And I believe I upgraded from 5.7 to 8, (it was a little while ago) – user3476463 Apr 21 '21 at 15:11
  • I tried running "sudo mysqld --upgrade=FORCE" and got the errors above. it seems like when I rebooted the ubuntu server something got messed up in my mysql maybe related to my past upgrade, and now the permissions with the users I've created are messed up. I can't create new users, I can't grant permissions to existing users, and I can't back up the db. any ideas what the issue might be? – user3476463 Apr 21 '21 at 15:29
  • Can you add the output of this statement: `select host,user,grant_priv,super_priv from mysql.user ;` This will show the users of your database, and from which `host` they can connect. – Luuk Apr 21 '21 at 15:43
  • BTW If you can log on locally, then you should be able to start mysqldump for that user too like this: `mysqldump -uroot -p --all-databases > dump_xxxxxx.sql`. If that does not work, please add full error message. – Luuk Apr 21 '21 at 15:56
  • @Luuk I added the output you requested as an update on my original post. I wasn't able to run mysqldump as user1. – user3476463 Apr 21 '21 at 23:35
  • There is too much unknown.... and to avoid a long discussion do some studying on [Connecting to the MySQL Server Using Command Options](https://dev.mysql.com/doc/refman/8.0/en/connecting.html). This link is only a starting point, I am not saying the answer is on that page. – Luuk Apr 22 '21 at 07:05

0 Answers0