Tuesday, February 19, 2019

Ubuntu mySQL Setting for remote access

1) Verify if is listenning
$wget --verbose http://localhost:3306
$wget --verbose http://192.168.0.12:3306
or
$nmap -sV localhost
$nmap -sV 192.168.0.12
or
$sudo netstat -tulpn
or
$sudo iptables -L -n

2) Verify file /etc/mysql/conf.d/  #include other possibles files
$sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf  #edit file and comment next line, or
$sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf

#bind-address        = 127.0.0.1

3) Add user


mysql>select user, host, authentication_string from mysql.user;

mysql>SHOW GRANTS FOR 'onepoint'@'%'; #if not exist

mysql> CREATE USER 'onepoint'@'localhost' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON Maxx2018.* TO 'onepoint'@'localhost' WITH GRANT OPTION;

mysql>CREATE USER 'onepoint'@'%' IDENTIFIED BY 'password';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'onepoint'@'%' WITH GRANT OPTION;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'onepoint'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;

4) Update user

mysql>use mysql;
mysql>update user set password=PASSWORD("NEWPASSWORD") where User='root'; 
mysql>flush privileges;


5) Common Errors


ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'


ERROR 1819 (HY000): Your password does not satisfy the current policy requirements



SET GLOBAL validate_password_policy=LOW;

You can edir /etc/mysql/my.cnf, but then you will have a security risk!
in [mysqld] add:
validate_password_policy=LOW




References:
[1] Firewall ubuntu https://stackoverflow.com/questions/30251889/how-to-open-some-ports-on-ubuntu
[2] https://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql


No comments:

Running apps

Runtastic (I uninstalled because force to update your device - Internet connection problems) Runkeeper  (Wrong GPS tracking) Strava   (Curr...