I wonder if there is any way to change localhost
in MariaDB.
For example, while creating a user in database, it shows
'user'@'localhost'
I would like to know how to change localhost
to any other hostname.
For example, I will be able to create a user in database like the following:
'user'@'mydomain.com'
By the way, I'm very new in MariaDB and SQL server stuff.
Thank you in advance!
2 Answers 2
The hostname component is the reference to the remote address of the connection. See create user.
Recommend keeping this constrained to a subnet.
Domain based grants while they look good, need reverse DNS setup to resolve this to an IP before allowing a connection. I recommend avoid them and using skip-name-resolve as a configuration option for extra speed and reliability.
-
Thank you for your response. I created a reverse lookup in order to resolve my IP to the server hostname, but it still doesn't work. I'm still getting this error: DSN (write): NOT OK (SQLSTATE[420000][1044] Access denied for user 'admin'@'test.com' to database 'webmail')alireza moosavi– alireza moosavi2021年04月03日 21:06:02 +00:00Commented Apr 3, 2021 at 21:06
-
if test.com doesn't resolve to the IP where you are connecting to the database (might be private IP address) from this is expected. Note again the recommendation not to use them.danblack– danblack2021年04月04日 00:21:31 +00:00Commented Apr 4, 2021 at 0:21
It's just a basic, You are suppose to mention hostname while creating user. Syntax is following :
CREATE USER 'user_name'@'host_name' IDENTIFIED BY 'yourpassword' ;
i.e.
CREATE USER 'myuser'@'192.168.3.12' IDENTIFIED BY 'MyU#123seR' ;
CREATE USER 'myuser'@'mydb.in' IDENTIFIED BY 'MyU#123seR' ;
GRANT SELECT ON *.* TO 'myuser'@'mydb.in' ;
You can also use special characters like '%'. Make sure you have properly checked your hostname in DNS entry.
Refer : https://dev.mysql.com/doc/refman/5.7/en/account-names.html
-
Thank you for your response. I followed what you suggested but I'm still getting this error: DSN (write): NOT OK (SQLSTATE[420000][1044] Access denied for user 'admin'@'test.com' to database 'webmail')alireza moosavi– alireza moosavi2021年04月03日 21:08:31 +00:00Commented Apr 3, 2021 at 21:08
-
have you checked you hostname is it correct , try doing ping on that hostname & check.JYOTI RAJAI– JYOTI RAJAI2021年04月04日 06:04:05 +00:00Commented Apr 4, 2021 at 6:04