Creating New MariaDB Databases: Difference between revisions
Jump to navigation
Jump to search
Tag: wikieditor |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
`Host` can be something like `localhost` or `'192.123.123. | `Host` can be something like `localhost` or `'192.123.123.%'`. <ref>[https://www.watchguard.com/help/docs/help-center/en-US/Content/en-US/Fireware/overview/networksecurity/slash_about_c.html About subnet mask slash notation]</ref> | ||
IP addresses need to be surrounded by quotes. Put the user name in quotes and the host in quotes, but not the `@` symbol. | IP addresses need to be surrounded by quotes. Put the user name in quotes and the host in quotes, but not the `@` symbol. | ||
Ranges in the IP can be specified with the `%` wildcard or subnet masks, e.g. `192.123.123.0/255.255.255.0`. | |||
Password is supplied as-is. Unencrypted and not passed through the `PASSWORD()` function. | Password is supplied as-is. Unencrypted and not passed through the `PASSWORD()` function. | ||
| Line 20: | Line 22: | ||
== Grant user access to database == | == Grant user access to database == | ||
To grant access to all objects in the database to a user: | |||
<syntaxhighlight lang="mysql"> | |||
GRANT ALL PRIVILEGES ON example_database.* TO 'user_name'@'192.168.123.%' IDENTIFIED BY 'my_password'; | |||
</syntaxhighlight> | |||
== Flushing privledges == | |||
Don't forget to flush the privledes after making changes: | |||
<syntaxhighlight lang="mysql"> | <syntaxhighlight lang="mysql"> | ||
FLUSH PRIVILEGES; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Reference == | == Reference == | ||
<references /> | <references /> | ||
[[Category:MariaDB]][[Category:MySQL]][[Category:Databases]][[Category:Web Development]] | |||
Latest revision as of 17:14, 7 September 2024
Create user[edit]
MariaDB User management knowledge base. [1]
CREATE OR REPLACE USER 'user_name'@'host' IDENTIFIED BY 'password';
Host can be something like localhost or '192.123.123.%'. [2]
IP addresses need to be surrounded by quotes. Put the user name in quotes and the host in quotes, but not the @ symbol.
Ranges in the IP can be specified with the % wildcard or subnet masks, e.g. 192.123.123.0/255.255.255.0.
Password is supplied as-is. Unencrypted and not passed through the PASSWORD() function.
Create database[edit]
CREATE DATABASE IF NOT EXISTS example_database;
Grant user access to database[edit]
To grant access to all objects in the database to a user:
GRANT ALL PRIVILEGES ON example_database.* TO 'user_name'@'192.168.123.%' IDENTIFIED BY 'my_password';
Flushing privledges[edit]
Don't forget to flush the privledes after making changes:
FLUSH PRIVILEGES;