When Psql is executed, no password is set.
The customer sent a lot of *. SQL files for creating database tables. If you run them one by one, it will be a waste of time. In this way, I implemented a batch processing file (BAT file) to operate multiple *. SQL statements at a time. However, this problem occurs because my batch processing is written like this:
@ Echo off
For % C in (*. SQL) Do Psql-D ucom-u ucom_user-F % C
Pause
In this way, Psql requires you to enter a password every time you run a *. SQL file. How can I cancel the password so that these files are processed at one time? I checked it online. There is a solution.
In the windwos environment, create a file such as % appdata % \ PostgreSQL \ pgpass. conf with the following content:
Hostname: Port: Database: Username: password where hostname is the host address, port is the database port, and the following three parameters are the database name, login user, and login password respectively. For example, my file is set as localhost: 5432: ucom: ucom_user. In this way, the above batch processing will be executed, and it will be OK once, and no password needs to be entered repeatedly. The variable % appdata % is a brief description of the application data path, which may be: C: \ Documents ents and Settings \ [user name] \ Application Data Directory.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/v_fei/archive/2007/11/19/1893562.aspx