Para criar uma base dados e um novo usuário para acessar essa base execute:
CREATE DATABASE my_database_name;
GRANT ALL PRIVILEGES ON my_database_name.* TO ‘new_username’@'localhost’ IDENTIFIED BY ‘my_password’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
Para criar uma base dados e um novo usuário para acessar essa base execute:
CREATE DATABASE my_database_name;
GRANT ALL PRIVILEGES ON my_database_name.* TO ‘new_username’@'localhost’ IDENTIFIED BY ‘my_password’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
Installing PostgreSQL from sources is a very easy and grateful task. It allow you to customize a lot of stuffs in your database server (I really appreciate the option of choose where to install my softwares, but this is not all).
You can get the PostgreSQL sources at http://www.postgresql.org/ftp/source/. I got the sources for the version 8.3.7, since it’s the latest stable version, so far.
Download psycopg2 at http://initd.org/pub/software/psycopg/
To install (I’m using the version 2.0.10) you need to run two commands:
# python setup.py build
and after the build is complete:
# python setup.py install
Well, but it’s not so easy if you do not have the dependencies already installed.In my case I got errors like:
NameError: global name ‘w’ is not defined psycopg2
or
error: Setup script exited with error: command ‘gcc’ failed with exit status 1
To solve this I have to install the libpq-dev library and the python development package:
# apt-get install libpq-dev
# apt-get install python2.5-dev
After that I just run the usual python setup.py install and all done.
Para criar um arquivo SQL com os inserts de uma base de dados do PosgreSQL (versão 8.3) execute o comando:
# pg_dump -i -h localhost -p 5432 -U <usuário> -F p -a -D -v -f “<nome do arquivo>.sql” -t ‘<schema>.*’ <database>
o executável normalmente se localiza em /usr/local/pgsql/bin/
Problema: alterar o locale do usuário para ISO8859-1 (poderia ser qualquer outro).
Solução: Edite o arquivo .bashrc e inclua as linhas:
export LANG=en_US.iso8859-1
export LC_CTYPE="en_US.iso8859-1"
export LC_NUMERIC="en_US.iso8859-1"
export LC_TIME="en_US.iso8859-1"
export LC_COLLATE="en_US.iso8859-1"
export LC_MONETARY="en_US.iso8859-1"
export LC_MESSAGES="en_US.iso8859-1"
export LC_PAPER="en_US.iso8859-1"
export LC_NAME="en_US.iso8859-1"
export LC_ADDRESS="en_US.iso8859-1"
export LC_TELEPHONE="en_US.iso8859-1"
export LC_MEASUREMENT="en_US.iso8859-1"
export LC_IDENTIFICATION="en_US.iso8859-1"
export LC_ALL="en_US.iso8859-1"
Nota:
source ~/.bashrc
Problema:
Você possui diversos domínios hospedados em um servidor Apache e deseja que todos eles sejam redirecionados para um outro domínio.
Solução:
Utilizar o mod_rewrite do apache com as seguintes condições e regra:
RewriteCond %{HTTP_HOST} ^dominio1.com(.*) [OR]
RewriteCond %{HTTP_HOST} ^www.dominio1.com(.*) [OR]
RewriteCond %{HTTP_HOST} ^outrodominio.com(.*) [OR]
RewriteCond %{HTTP_HOST} ^paraquetantodominio.com(.*)
RewriteRule ^/(.*) http://www.dominioprincipal.com/$1 [L,R=301]
Notas:
Para criar um novo projeto em Django execute o comando:
django-admin startproject <nome projecto>
com isso será criada a seguinte estrutura:
mysite/
__init__.py
manage.py
settings.py
urls.py
continua…
Para criar um usuário no Oracle utilizando um tablespace sem limite de espaço, com o nome meuusuario e senha minhasenha com alguns privilégios básicos para conseguir logar, criar e apagar tabelas e outros objetos execute:
CREATE TABLESPACE meutablespace LOGGING DATAFILE ‘/oracle10/oradata/minhabase/meutablespace.dbf‘ SIZE 32m AUTOEXTEND ON NEXT 32m EXTENT MANAGEMENT LOCAL;
CREATE USER meuusuario IDENTIFIED BY minhasenha DEFAULT TABLESPACE MEUTABLESPACE QUOTA UNLIMITED ON MEUTABLESPACE;
GRANT create session, alter session, select_catalog_role, execute_catalog_role, create table, create procedure, create view, create materialized view, create trigger, create sequence, create any directory, create type, create synonym, administer database trigger TO meuusuario;
Observações: Eu testei estes comandos no Oracle 10G.
And now in english:
To create a user in Oracle with an unlimited tablespace, with username myuser, password mypass and with the basic privileges in order to login, create and remove tables and some other objects run:
CREATE TABLESPACE mytablespace LOGGING DATAFILE ‘/oracle10/oradata/mybase/myablespace.dbf‘ SIZE 32m AUTOEXTEND ON NEXT 32m EXTENT MANAGEMENT LOCAL;
CREATE USER myuser IDENTIFIED BY mypass DEFAULT TABLESPACE mytablespace QUOTA UNLIMITED ON mytablespace;
GRANT create session, alter session, select_catalog_role, execute_catalog_role, create table, create procedure, create view, create materialized view, create trigger, create sequence, create any directory, create type, create synonym, administer database trigger TO myuser;
Note: I’d tested this on Oracle 10G
Para resetar a senha do MySQL:
- Pare o MySQL caso esteja sendo executado.
- Inicie o daemon mysqld com o parâmetro –skip-grant-tables.
- Inicie o cliente do MySQL com os parâmetros -u root.
- Execute o comando: UPDATE mysql.user SET PASSWORD=PASSWORD('novopassword') WHERE User='root';
- Execute o comando: FLUSH PRIVILEGES
- Pare o daemon mysqld e o inicie normalmente.