4,348
edits
iwu |
→listing all tables: add Change the password of a user |
||
(2 intermediate revisions by the same user not shown) | |||
Line 29: | Line 29: | ||
postgres=# create database mydb; | postgres=# create database mydb; | ||
postgres=# grant all privileges on database mydb to dbuser; | postgres=# grant all privileges on database mydb to dbuser; | ||
</syntaxhighlight> | |||
== Listing DBs == | |||
You can list the DBs. | |||
MySQL: | |||
<syntaxhighlight lang="mysql"> | |||
mysql> show databases; | |||
</syntaxhighlight> | |||
PostgreSQL: | |||
<syntaxhighlight lang="psql"> | |||
postgres=# \l | |||
</syntaxhighlight> | |||
== selecting a DB == | |||
You can select a DB. | |||
MySQL: | |||
<syntaxhighlight lang="mysql"> | |||
mysql> use mydb; | |||
</syntaxhighlight> | |||
PostgreSQL: | |||
<syntaxhighlight lang="psql"> | |||
postgres=# \connect mydb; | |||
</syntaxhighlight> | |||
After selecting a DB you can go ahead and execute SQL commands. | |||
== listing all tables == | |||
You can list tables in a DB. | |||
MySQL: | |||
<syntaxhighlight lang="mysql"> | |||
mysql> show tables; | |||
</syntaxhighlight> | |||
PostgreSQL: | |||
<syntaxhighlight lang="psql"> | |||
postgres=# \dt | |||
</syntaxhighlight> | |||
== Change the password of a user == | |||
You can list tables in a DB. | |||
MySQL: | |||
<syntaxhighlight lang="mysql"> | |||
mysql> set password for 'dbuser'@'localhost' = password('newpassword'); | |||
</syntaxhighlight> | |||
PostgreSQL: | |||
<syntaxhighlight lang="psql"> | |||
postgres=# alter user "dbuser" with password 'newpassword'; | |||
</syntaxhighlight> | </syntaxhighlight> | ||