zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Migrate MySQL users

December 24, 2020 by Igor Drobot Leave a Comment

Following line will query all mysql user with their grants and print the creation statements for them.

By copy pasting or by filling a SQL-file, you can easily migrate all MySQL-user to a new mysql or mariaDB instance.

mysql -u root -p"YOUR_PW" -Ne "select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from mysql.user;" mysql | \
mysql -u root -p"YOUR_PW"| \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'

Filed Under: Linux Tagged With: MariaDB, Migrate MySQL User, MySQL, SQL

Postgresql

August 26, 2010 by Igor Drobot Leave a Comment

 

Some basic postgre commands:




\d [NAME] describe table, index, sequence, or view \d{t|i|s|v|S} [PATTERN] (add "+" for more detail) list tables/indexes/sequences/views/system tables \da [PATTERN] list aggregate functions \db [PATTERN] list tablespaces (add "+" for more detail) \dc [PATTERN] list conversions \dC list casts \dd [PATTERN] show comment for object \dD [PATTERN] list domains \df [PATTERN] list functions (add "+" for more detail) \dg [PATTERN] list groups \dn [PATTERN] list schemas (add "+" for more detail) \do [NAME] list operators \dl list large objects, same as \lo_list \dp [PATTERN] list table, view, and sequence access privileges \dT [PATTERN] list data types (add "+" for more detail) \du [PATTERN] list users \l list all databases (add "+" for more detail)

Filed Under: Linux Tagged With: Database, postgresql, SQL

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok