Install configuration on Mac and easy to use PostgreSQL (still not understand)

Source: Internet
Author: User
Tags postgresql psql create database postgres database


Tag:sql   lib   mac   sq    boot     style   data    connection    iv   



Because you want to use the recommended rails-template. Need to use Postgres. And initializes a user postgres, the password is postgres. (e.g. $ createuser -d postgres )






Need to buy a copy of the relevant database book to read. Briefly look at the simplified instructions for use on the Internet: (original link)






I have used the brew install PostgreSQL installation and have set up boot brew services start PostgreSQL



Go to console PostgreSQL:



Psql



Use \l to list so the database. There is already a database with the same name as the user, Postgres database



I installed the original text operation, entered the command, but did not have any hint. Finally see \l, no change, I think it is my operation in which position error.



From the new setting password to Postgres








chentianwei=# CREATE USER postgres with PASSWORD ' Postgres '




chentianwei-# \lchentianwei-# CREATE DATABASE exampledb OWNER postgreschentianwei-# \lchentianwei-# GRANT all privileges On DATABASE Exampledb to Postgres


Then use psql-u postgres-d postgres



There is no change to the database entered \l listed in the database entry.






List of commands:


\password: Sets the password for the currently logged on user


\h: View an explanation of the SQL command, such as \h Select.



\?: View the list of PSQL commands. \l: Lists all databases.



\c [database_name]: Connect to a different database.



\d: Lists all tables for the current database.



\d [table_name]: Lists the structure of a table.



\DU: Lists all users.



\e: Opens a text editor. \conninfo: Lists the current database and connection information.



\password [user]: Modify user password



\q: Exit









Install configuration on Mac and easy to use PostgreSQL (still not understand)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.