Granting Access to Users With MySQL
To grant access to a database for a particular user and subnet, you can use this command:
mysql> grant all privileges on arewedown.* to are@'10.50.100.0/255.255.255.0'
identified by 'arepass';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> select User,Host from mysql.user;
+------+---------------------------+
| User | Host |
+------+---------------------------+
| are | 10.50.100.0/255.255.255.0 |
| root | localhost |
| root | srv-1.networking7by24.com |
+------+---------------------------+
3 rows in set (0.01 sec)
mysql>
|
In this example, all privileges are granted to all tables in the database arewedown to the user are, connecting from 10.50.100.0-10.50.100.255.
Note that there is a difference in the error received for an invalid password vs. an invalid host. Here is an error show for an invalid password from a test for the MySQL ODBC connector:
Notice that there is no immediate disconnect when you telnet to port 3306. If the user/host is not allowed, you will see a different error:
Here, even if you telnet to port 3306, you will immediately be kicked off.
For more information on the GRANT command for MySQL and associated commands, see this page.
|
|