zoukankan      html  css  js  c++  java
  • postgresql

    登陆: window: psql -U name linux: psql -U name -h IP

    向PostgreSql数据库中导入.sql文件: psql -U username -W -d dbname -f xx.sql

    删除有外键关系的表:drop table tablename cascade;

    修改自增长起始数据:alter sequence sequence_name restart with 100;

    ---------------------------------------PostgresSQL数据库在ubuntu上的安装步骤------------------------------

    ----------------------------------------------------------------------------------------------------------

    1.apt-get update 更新源,否则有可能会发生url not found 的现象

    2.sudo apt-get install postgresql 安装数据库,我们的版本是PostgreSQL-9.3

    3.安装完后会有PostgreSQL的客户端psql,通过 sudo -u postgres psql 进入,提示符变成: postgres=#

    4.修改密码:alter user postgres with password '123456'; 5.导入创建数据库和创建表格的脚本

    # 6,7,8 的作用是配置数据库以允许远程连接访问(用于测试,实际项目可忽略)

    # 6.修改监听地址:sudo gedit /etc/postgresql/9.5/main/postgresql.conf 将 #listen_addresses = 'localhost' 的注释去掉并改为 listen_addresses = '*'

    #7.修改可访问用户的IP段:sudo gedit /etc/postgresql/9.5/main/pg_hba.conf 在文件末尾添加: host all all 0.0.0.0 0.0.0.0 md5 ,表示运行任何IP连接

    #8.重启数据库:sudo /etc/init.d/postgresql restart

    #登陆 peer connection : sudo -u postgres psql

            password connection :psql -U postgres -h localhost

    ---------------------------------------------------------------------------------------------------------

    参考1

    参考2

  • 相关阅读:
    015.Python函数名的使用以及函数变量的操作
    014.Python函数
    013.Python的文件操作
    012.Python的字典和集合的相关函数
    git入门
    Visual Studio 常见的快捷键
    SVN使用
    C++ 一些特性
    C++ 引用、构造函数、移动语义
    WPF的AutoCompleteBox控件
  • 原文地址:https://www.cnblogs.com/lwmp/p/6255360.html
Copyright © 2011-2022 走看看