![]() ![]() ![]() Two essential tools that you'll find yourself using often are pg_dump and pg_restore. To change your password: alter user username with encrypted password 'new_password' Make sure to back up your database before dropping it or make sure you are not using it, as the process is irreversible Change user password To drop a database: drop database databasename To grant a user access to a database: grant all privileges on database databasename to username To create a new user: create user username with password 'password' To create a new database: create database databasename Creating database, user, and granting accessĬreating a user, and granting users access to a database are fundamental tasks in database management that you'll always use in your development workflow. Once authenticated, you can interact with the remote database as if it were a local database. You can replace localhost with the address of the remote server if you are connecting to a remote database and not your local database.Īfter entering this command, you will be prompted to enter the PostgreSQL password. To connect to a local or remote database $ psql -h localhost -p 5432 -U username -d databasename To connect to your local server $ sudo psql -U -d postgres This works in PostgreSQL as of version 14.4 on 8 April 2023. These commands allow you to efficiently manage your databases and perform various tasks such as creating tables, querying data, and managing user permissions. Whether you're a beginner or an experienced user, I hope this becomes a useful resource for increasing productivity and saving time for you working with PostgreSQL.Īs a software developer who frequently works with databases, you would often find yourself using these commands daily. This post provides you with a PostgreSQL command cheat sheet to help you reference the most useful commands and syntax for developers on Mac OS. PostgreSQL commands for software developers using Mac OS ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |