This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
db_command_tutorial [2015/05/22 09:11] stephdl created |
db_command_tutorial [2015/05/22 10:17] stephdl |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | == Database variables | + | ===== Db command tutorial ===== |
- | NethServer comes with the most used parameters set as variables in its internal configuration databases. These variables are used to store values to be used in the final configuration files. Please, read the http:// | + | NethServer comes with the most used parameters set as variables in its internal configuration databases. These variables are used to store values to be used in the final configuration files. Please, read the [[http:// |
These variables are useful to configure your system more easily, as you do not need to modify configuration files directly for most common cases. It also makes it possible to administer the server through its server-manager as the database variables are used to set and change configuration parameters. | These variables are useful to configure your system more easily, as you do not need to modify configuration files directly for most common cases. It also makes it possible to administer the server through its server-manager as the database variables are used to set and change configuration parameters. | ||
Line 9: | Line 9: | ||
You would simply execute these commands at the server console: | You would simply execute these commands at the server console: | ||
- | db configuration setprop php MemoryLimit | + | db configuration setprop php MemoryLimit |
signal-event nethserver-php-save | signal-event nethserver-php-save | ||
- | The first line changes the value for the memory limit of PHP, the second line regenerates the configuration file and the last line will reload Apache (and subsequently also PHP as this is configured as a module of Apache). | + | The first line changes the value for the memory limit of PHP, the second line regenerates the configuration file and restart apache. |
+ | <WRAP center round alert 60%> | ||
+ | **The signal-event | ||
+ | </ | ||
<WRAP center round tip 60%> | <WRAP center round tip 60%> | ||
Line 19: | Line 22: | ||
- | The database system is based on a flat file system, but you should never edit them directly. Instead you should use the db command. More details on using the database system can be found in the [http://mirror.contribs.org/smeserver/contribs/gordonr/devguide/html/ | + | The database system is based on a flat file system, but you should never edit them directly. Instead you should use the db command. More details on using the database system can be found in the [[http://docs.nethserver.org/projects/nethserver-devel/en/latest/index.html|Developer |
+ | =====Auto completion===== | ||
- | === Setting db variables to default values | + | Like in every Linux shell you can use the TAB key when you use the command line to auto complete or propose all available answers |
+ | |||
+ | =====Usage===== | ||
<WRAP center round tip 60%> | <WRAP center round tip 60%> | ||
Use of ' | Use of ' | ||
</ | </ | ||
+ | ====Keys/ | ||
+ | |||
+ | All turn around A key with properties and values of the properties, no more, no less. You can have a lot of properties under a key which is unique | ||
+ | |||
+ | # db configuration show passwordstrength | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | Apply the above " | ||
+ | |||
+ | Note that missing (or no) properties and values do not necessarily mean no value is in the / | ||
+ | |||
+ | Note to determine what db settings are supported by sme code, or what the default values are, refer to (ie read) the code that is in the particular template or custom template associated with a / | ||
+ | Look in / | ||
+ | and subfolders and template fragments applicable to particular / | ||
+ | |||
+ | |||
+ | ====show all available databases==== | ||
+ | To show a list of existing databases do | ||
+ | ls -al / | ||
+ | |||
+ | To show the keys for the two main databases do: | ||
+ | db configuration show |less | ||
+ | That can be abbreviated to | ||
+ | config show |less | ||
+ | |||
+ | db accounts show |less | ||
+ | |||
+ | Note after using the |less switch, press Enter to scroll down a line at a time, or press Space to scroll down a page at a time. ' | ||
+ | ====Create a key in a database==== | ||
+ | the generic command is : | ||
+ | db dbfile set key type [prop1 val1] [prop2 val2] ... | ||
+ | |||
+ | dbfile : choose the database in / | ||
+ | key : the name of key | ||
+ | type : generally ' | ||
+ | |||
+ | If you want to create a keys called ' | ||
+ | |||
+ | db configuration set plop configuration Name wordpress PublicAccess private status enabled DbName wordpress DbUser wordpress WpLang en | ||
+ | |||
+ | you can see the result | ||
+ | |||
+ | config show plop | ||
+ | or | ||
+ | db configuration show plop | ||
+ | |||
+ | plop=configuration | ||
+ | DbName=wordpress | ||
+ | DbUser=wordpress | ||
+ | Name=wordpress | ||
+ | PublicAccess=private | ||
+ | WpLang=en | ||
+ | status=enabled | ||
+ | |||
+ | ====Change values of properties==== | ||
+ | The generic command line is | ||
+ | db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ... | ||
+ | |||
+ | |||
+ | dbfile : choose the database in / | ||
+ | key : the name of key | ||
+ | |||
+ | Then if you want to modify some values of our example above | ||
+ | db configuration setprop plop PublicAccess public WpLang fr | ||
+ | or | ||
+ | config setprop plop PublicAccess public WpLang fr | ||
+ | |||
+ | We want to verify | ||
+ | config show plop | ||
+ | or | ||
+ | db configuration show plop | ||
+ | |||
+ | plop=configuration | ||
+ | DbName=wordpress | ||
+ | DbUser=wordpress | ||
+ | Name=wordpress | ||
+ | PublicAccess=public | ||
+ | WpLang=fr | ||
+ | status=enabled | ||
+ | |||
+ | ====Create a property under a key==== | ||
+ | |||
+ | Same as above, really not difficult | ||
+ | |||
+ | db configuration setprop plop PlopTheWorld YES | ||
+ | or | ||
+ | config setprop plop PlopTheWorld YES | ||
+ | |||
+ | and to display modification | ||
+ | |||
+ | db configuration show plop | ||
+ | or | ||
+ | config show plop | ||
+ | |||
+ | plop=configuration | ||
+ | DbName=wordpress | ||
+ | DbUser=wordpress | ||
+ | Name=wordpress | ||
+ | PlopTheWorld=YES | ||
+ | PublicAccess=public | ||
+ | WpLang=fr | ||
+ | status=enabled | ||
+ | |||
+ | ==== Setting db variables to default values ==== | ||
+ | <WRAP center round tip 60%> | ||
+ | Use of ' | ||
+ | </ | ||
+ | |||
Any db variable that has a default value can be reset to the default by deleting the variable entirely, then re-initializing the default database values as follows: | Any db variable that has a default value can be reset to the default by deleting the variable entirely, then re-initializing the default database values as follows: | ||
- | | + | config delprop <key> < |
+ | / | ||
+ | |||
+ | for example | ||
+ | db configuration delprop plop WPlang | ||
+ | / | ||
+ | or | ||
+ | config delprop plop WpLang | ||
/ | / | ||
==== Delete a property value ==== | ==== Delete a property value ==== | ||
To delete the property | To delete the property | ||
- | db accounts | + | db dbfile |
+ | for example | ||
+ | db configuration delprop plop WpLang | ||
+ | or | ||
+ | config delprop plop WpLang | ||
- | ==== Reset a property value ==== | + | ==== Delete a Key ==== |
+ | To delete the Key | ||
+ | db dbfile delete < | ||
+ | for example | ||
+ | db configuration delete plop | ||
+ | or | ||
+ | config delete plop | ||
+ | |||
+ | ==== Reset a property | ||
To reset to an empty value | To reset to an empty value | ||
- | | + | db dbfile |
+ | |||
+ | for example | ||
+ | db configuration setprop plop WpLang '' | ||
+ | or | ||
+ | config setprop plop WpLang '' | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | Database parameters are case sensitive so take great care when typing at the server shell because no error messages are given should you make a mistake. | ||
+ | </ | ||
+ | {{tag> neth-howto }} |