2

I need to create new user on my Mysql database. The user should be a accessed from any end point and have all privileges.

Actually, I can't understand what is the meaning of the host column in my mysql.user table.

Which sql statement I need to write for this?

Thanks!!

1

1 Answer 1

1

The first thing you have to check is that your mysql server can receive connection from the outside. So check in my.ini config file the value of bind-address property.

Tipically you have to change it from

bind-address=127.0.0.1

to

bind-address=0.0.0.0

Then restart your server.

Now you can add your user specifying the wildcard character % for host column. This allow your specified user from any host to your setted privileges.

Then you can create your user:

CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
CREATE USER 'newuser'@'192.168.%.%' IDENTIFIED BY 'password';

and grand privileges on schemas/tables:

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

Instead of grant ALL privileges, you can grant:

CREATE - allows them to create new tables or databases

DROP - allows them to them to delete tables or databases

DELETE - allows them to delete rows from tables

INSERT - allows them to insert rows into tables

SELECT - allows them to use the Select command to read through databases

UPDATE - allow them to update table rows

GRANT OPTION - allows them to grant or remove other users' privileges

At the end flush your privileges: FLUSH PRIVILEGES;

The general syntax of GRANT is:

GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

You can use a tool like MySql Workbench to simplify this task.

Hope this helps.

Sign up to request clarification or add additional context in comments.

5 Comments

In /etc/mysql tipically
can't find it there.. any place else ?
find / -name my.cnf ..or try my.ini
@RoeyGolzarpoor which distro are you using? are you installing mysql from distro package installer (apt / emerge / ..) or from sources?
The mysql is already been installed. Now I need to create new user that I can access him from anywhere. Isn't it just a simple sql statement ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.