Difference between revisions of "MySQL user creating and allow connecting from custom IP"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<br><br>
<br><br>
==About==
=About=
MySQL user creating and allow connecting from custom IP.<br>
MySQL user creating and allow connecting from custom IP
<br><br>
=='''Login'''==  
=='''Login'''==  
At first login to mysql database as root <br>
At first login to mysql database as root <br>
type this into terminal:<br>
type this into terminal:<br>
  mysql -u root -p  
  mysql -u root -p  
When issue such commands:<br>
When issue such commands:
<br><br>
<br><br>
=='''To create user'''==
=='''To create user'''==
                                 enter ip
                                 enter ip
  CREATE USER 'enterusername'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'enterpassword';
  CREATE USER 'enterusername'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'enterpassword';
To set all privileges<br>
To set all privileges  
<br><br>
<br><br>
=='''To set Privileges '''==  
=='''To set Privileges '''==  
Line 19: Line 20:
If you still can not connect check or port 3306 is open <br>
If you still can not connect check or port 3306 is open <br>
  nmap -sS -O 127.0.0.1<br>
  nmap -sS -O 127.0.0.1<br>
if port 3306 is not open. You need open port:<br>
if port 3306 is not open. You need open port:
<br><br>
<br><br>
=='''Open MySQL port '''==  
=='''Open MySQL port '''==  
Line 25: Line 26:
Save iptables configuration:<br>
Save iptables configuration:<br>
  service iptables save<br>
  service iptables save<br>
<br><br>
=='''Connecting from remote server '''==
mysql -u <enter username> -h <database server ip address> -p
<br><br>
= See also =
* [[Mysql read only User]]

Latest revision as of 08:31, 31 May 2019



About

MySQL user creating and allow connecting from custom IP

Login

At first login to mysql database as root
type this into terminal:

mysql -u root -p 

When issue such commands:

To create user

                               enter ip
CREATE USER 'enterusername'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'enterpassword';

To set all privileges

To set Privileges

                                                     enter ip
GRANT ALL PRIVILEGES ON mor.* TO 'enterusername'@'xxx.xxx.xxx.xxx' WITH GRANT OPTION ;

Now you can connect from your entered ip to mysql.
If you still can not connect check or port 3306 is open

nmap -sS -O 127.0.0.1

if port 3306 is not open. You need open port:

Open MySQL port

iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

Save iptables configuration:

service iptables save



Connecting from remote server

mysql -u <enter username> -h <database server ip address> -p



See also