To turn on MySQL remote access permissions: log on to the MySQL service on a Linux system.
-- Root is the user name [[email protected] ~] - - -- Enter password
To create a remote connection to MySQL User:
--Create a user, password, and permission range the first Roo T is the user name @ after the applicable host, '% ' means all computers can access the connection, the second root is a passwordMysql> GRANT All Privileges on *.* to 'Root'@'192.168.0.2'Identified by 'Root' with GRANT OPTION; Query OK,0Rows Affected (1.57sec)--Immediate effectMysql>FlushPrivileges; Query OK,0Rows Affected (0.00Sec
To view database users:
--using the MySQL libraryMysql> UseMySQL; ReadingTableInformation forCompletion of Table and columnnamesyou can turnoffThis feature toGet a quicker startup with -ADatabasechanged--View UserMysql> SELECT DISTINCTCONCAT ('User: [',User," "@" ", host,'];') asUser_host from User; +---------------------------------------+|User_host|+---------------------------------------+| User: [Root ' @ ' 127.0.0.1]; || User:[root ' @ ' 192.168.0.2];|| User:[root ' @ ':: 1];|| User:[root ' @ ' localhost];|| User:[root ' @ ' Localhost.localdomain];|+---------------------------------------+5Rowsinch Set(0.00Sec
Created successfully.
To view ports:
Mysql>Show global variables like 'Port';+---------------+-------+|Variable_name|Value|+---------------+-------+|Port| 3306 |+---------------+-------+1Rowinch Set(0.01Sec
Turn on port 3306:
[[email protected] ~]# VIM/etc/Sysconfig/iptables# Firewall Configuration written bySystem-Config-firewall# Manual Customization ofThisfile is notrecommended.*filter:input ACCEPT[0:0]: FORWARD ACCEPT[0:0]: OUTPUT ACCEPT[0:0]-A INPUT-M state--State Established,related-j ACCEPT-A INPUT-P ICMP-J ACCEPT-A INPUT-I lo-J ACCEPT-A INPUT-M state--State new-m tcp-p TCP--dport 22-j ACCEPT-A input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT-A INPUT-J REJECT--Reject-with icmp-host-prohibited-A FORWARD-J REJECT--Reject-with icmp-host-prohibitedCOMMIT "/etc/Sysconfig/Iptables "14L, 543C
Note: Be sure to add the front of the second line.
To restart the firewall:
[ [email protected] ~ ] # service iptables restartiptables: Set the chain as policy Accept:filter [ " iptables: Clear Firewall rule: [ " iptables: Unloading module: [ " iptables: Apply firewall rule: [ "
To view the server IP address:
[[email protected] ~]# ifconfigeth0 Link encap:ethernet HWaddrxx: 0C: in: -: F4:e6 inet Addr: 192.168. 0.123 Bcast:192.168.0.255Mask:255.255.255.0Inet6 Addr:hjjj:jjji::iii:oooo:oooo:ioio/ -scope:link up broadcast RUNNING multicast MTU: theMetric:1RX Packets:2931Errors0Dropped0Overruns:0Frame0TX Packets:1631Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen: +RX Bytes:322681(315.1KiB) TX Bytes:266043(259.8KiB) Lo Link encap:local Loopback inet addr:127.0.0.1Mask:255.0.0.0Inet6 Addr: ::1/ -scope:host up LOOPBACK RUNNING MTU:16436Metric:1RX Packets:0Errors0Dropped0Overruns:0Frame0TX Packets:0Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen:0RX Bytes:0(0.0b) TX Bytes:0(0.0b
Connection test:
Setting up MySQL in Linux server allows remote access