There are few ways you can create a new user for a MySQL DB.
- Using grant command to create a new user and assign privileges to access a DB.
- Use the create user mysql command followed by grant command to set access privileges.
- Directly editing the mysql DB using insert, update etc (which is a bit complex)
Create USER
For creating user following command is used
CREATE USERuser
[IDENTIFIED BY [PASSWORD] 'password
']
The above command creates a new user, but who has no access to any DB. In order to grant prermissions to access any DB, we need to use the grant command.
Grant Command
GRANT ALL ON *.* TO 'someuser'@'somehost';
The above will grant ALL the permission (select, insert, updat, delet etc) to someuser at somehost. If you would like to set a user from a particular IP to access the DB, you can use like
GRANT ALL ON *.* TO 'someuser'@'IPADDRESS';
The following command will give only select and insert privileges to someuser at somehost
GRANT SELECT, INSERT ON *.* TO 'someuser'@'somehost';
Why to struggle so much.. we can use SQLYog and use the inerface.
Thats a good client tool to access DB.
hmm 😉 All are spoon fed to a level where in you need not even write queries 🙂
in mysql5, i believe we can specify the resource that each mysql user can consume , like number of questions ( queries ) he can run , number of connections he can make at a time etc which I do not think is able to manipulate vis the web interface 🙂