For quick access or when enabling remote access is not possible, ssh tunneling/port forwarding can be used to access a database (that is not allowed to be accessed remotely) temporarily
First create a SSH session with port forwarding
ssh -L 3300:localhost:3306 user@server
Then connect using the local port on local machine
mysql -P 3300 -uuser -p
modify conf file
vi /etc/mysql/mysql.conf.d/mysqld.cnf
and comment out the following line (i.e., disable it, mysql be default listens to only local machine)
bind-address = 127.0.0.1
restart mysql server
sudo service mysql restart
if new user needed
mysql> create user 'username'@'localhost' identified by 'password';
allow access from all machines
mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
or from specific ip
mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
check to make sure
SELECT * from information_schema.user_privileges where grantee like "'username'%";
and run
mysql> FLUSH PRIVILEGES;
revoke all options for username from all machines
mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'%';
revoke all options for username from particular IP:
mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'1.2.3.4';