Wednesday, May 29, 2013

Postgresql and setting schema search path other than public

Example DB Server: 192.168.1.10
Example DB: company_live_prod
Default Schema: public
Other Schema: com_retail_store

Upon logging on postgres cli, default schema of public will take effect. The ff: will set to change the schema so you can check the tables under that other schema.


assuming that I am now login as postgres and able to access the db on default public schema.

company_live_prod=# \dt
                                List of relations
 Schema |                        Name                        | Type  |   Owner   
--------+----------------------------------------------------+-------+------------
 public | access_levels                                      | table | xuser
 public | to_for                 | table | xuser
 public | super_hierarchy                             | table | xuser
 public | sked01                         | table | xuser






so that I can see the tables for the other schema, below command will do.


company_live_prod=# SET search_path TO  com_retail_store;
SET
ces_live_final=# \dt
                    List of relations
     Schema      |         Name         | Type  |  Owner 
-----------------+----------------------+-------+---------
 com_retail_store | com_assign_module    | table | xuser
 com_retail_store | com_cart             | table | xuser
 com_retail_store | com_category         | table | xuser
 com_retail_store | com_item_storage     | table | xuser
 com_retail_store | com_manual_upload    | table | xuser
 com_retail_store | com_point_metrics    | table | xuser

(06 rows)







Default schema is now the none public schema.











Friday, May 24, 2013

How to Reset mysql root password if you forgot it

1. Login as root on the server
2. Stop the mysql service
3. start the mysql service on safemode
           command: mysqld_safe --skip-grant-tables
4. Login or if you have a ready alternate console, you can now do mysql command which will login with out password then do the sql command below:

           update mysql.user set Password=PASSWORD('NeWPassWord') WHERE User='root';


5. Exit and restart the mysql service as normal restart.
6. You can now login using the new password.