数据库杂记

Postgres导出

\o 文件名 select * from table ; \o

\copy (select parent_id+123456789,count(*) cnt from user_relations where user_id between 24304192 and 24368430 and parent_id != 1 group by parent_id order by cnt desc) To ‘/tmp/sf.csv’ With CSV

Mysql初始化

初始化

mysqld --user=mysql  --datadir=/datas/mysql --initialize-insecure

重设密码

service mysql stop
[mysqld] skip-grant-tables
update user set authentication_string = password('Aa12345678') where user = 'root';
flush privileges;
set global validate_password_policy=0;
ALTER USER 'root'@'localhost' identified by 'Aa12345678' ;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Aa12345678' WITH GRANT OPTION;