Web Hosting Talk







View Full Version : Restricting MySQL Access from Command Line


allan
08-04-2001, 12:57 PM
Normally I use webmin to do this, but i am having a problem with the User Permissions section of the webmin MySQL module.

What I want to do is restrict access to a MySQL database so the user can only come from a certain IP address. I tried the following command:


mysql> insert into db
-> (host,db,user,Select_priv,Insert_priv,Update_priv,Delete_priv,
-> Create_priv,Drop_priv)
-> values ('ipaddress','dbname','username','Y','Y','Y','Y','Y','Y');


However, I get a 1064 error when I do that. Do you all have any idea what they right command is?

Thanks!

mikeknoxv
08-05-2001, 10:57 AM
My best guess:

INSERT INTO user (Host,User,Password)
VALUES('localhost','custom',PASSWORD('stupid'));

INSERT INTO user SET Host='localhost',User='admin',
Reload_priv='Y', Process_priv='Y';

I would reccomend searching the MySQL docs at http://www.mysql.com/doc/

anna
08-06-2001, 01:24 PM
You need to update the 'user' table, as well as the 'db' table.

So you would do the following:

insert into user (Host, User, Password, ....)
values ('ipaddress', 'username', password('password'),...)

(replace the '...' with the various other fields in the table and the permissions you want to give the user)

After you have inserted the record, be sure to reload MySQL!

mysqladmin reload -u root -prootpw

Hope that helps.