【发布时间】:2012-10-05 02:18:20
【问题描述】:
我不知道:
- 只需登录到 postgreSQL
- 创建数据库
- 添加表格
- 插入记录
- 删除、更新等
这些事情通常使用 mysql 非常容易。有人可以帮我设置以下 postgresql 的替代方案吗
a) Reset 默认密码——非常简洁的描述, 我没有发现 PostgreSQL 的清晰程度相同 (任何文档链接都非常感谢)
b) 我们知道 mysql 的超级用户是“root”,而 PostgreSQL 也是如此
c) 从命令行如何(PostgreSQL 的?):
mysql -uroot -proot
create database testdb;
use testdb;
create table test(id int(11) auto_increment, name varchar(20), primary key(id));
insert into test(name) values("testing one"),("testing two"),("testing three"),("testing four");
select * from test;
update test set name=concat(name,now()) where id =3;
delete from test where id =4;
drop table if exists test;
drop database if exists testdb;
编辑 MAC 操作系统 # 默认密码重置
sudo mate /Library/PostgreSQL/9.2/data/pg_hba.conf
替换(md5 信任)
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
与
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
保存
执行了 Reload Configuration.app
login to postgresql without password :
$ psql -U postgres
postgres# ALTER USER postgres WITH PASSWORD 'new password';
\q
-还原 pg_hba.conf 中的所有更改(用 md5 替换 trust)并保存
-重新加载配置
现在我可以使用新密码登录 postgresql
psql -U postgres
Password for user postgres:[my new password]
【问题讨论】:
-
@BurhanKhalid 非常感谢,但仍然无法登录到 postgreSQL :(
-
你可以从终端登录为` psql -d postgres_db_name -U postgres`
-
@Thanga,我不知道默认用户和密码,这就是我试图直接弄清楚的
标签: mysql postgresql-9.2