linux:mariadb:mariadb-queries
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:mariadb:mariadb-queries [2020/10/23 09:44] – external edit 127.0.0.1 | linux:mariadb:mariadb-queries [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== MariaDB Common Queries ===== | ||
| - | ===== Query Databases ===== | ||
| - | < | ||
| - | MariaDB [(none)]> | ||
| - | +--------------------+ | ||
| - | | Database | ||
| - | +--------------------+ | ||
| - | | information_schema | | ||
| - | | mysql | | ||
| - | | nextcloud | ||
| - | | performance_schema | | ||
| - | | sitedatabase | ||
| - | +--------------------+ | ||
| - | </ | ||
| - | ===== Query Users ===== | ||
| - | < | ||
| - | MariaDB [(none)]> | ||
| - | +-----------+----------+-------------------------------------------+ | ||
| - | | host | user | password | ||
| - | +-----------+----------+-------------------------------------------+ | ||
| - | | localhost | root | *AF926838A9A0501BA7017D135C123C007497F85B | | ||
| - | | localhost | www-data | *AF926838A9A0501BA7017D135C123C007497F85B | | ||
| - | | localhost | nc-user | ||
| - | +-----------+----------+-------------------------------------------+ | ||
| - | MariaDB [(none)]> | ||
| - | +----------+--------------+-----------+ | ||
| - | | User | Db | Host | | ||
| - | +----------+--------------+-----------+ | ||
| - | | nc-user | ||
| - | | www-data | sitedatabase | localhost | | ||
| - | +----------+--------------+-----------+ | ||
| - | </ | ||
| - | ===== Create Users ===== | ||
| - | < | ||
| - | CREATE USER ' | ||
| - | CREATE USER ' | ||
| - | </ | ||
| - | ===== Query Users Rights ===== | ||
| - | < | ||
| - | MariaDB [(none)]> | ||
| - | +------------------------------------------------------------------------------------------------+ | ||
| - | | Grants for root@localhost | ||
| - | +------------------------------------------------------------------------------------------------+ | ||
| - | | GRANT ALL PRIVILEGES ON *.* TO ' | ||
| - | | GRANT PROXY ON '' | ||
| - | +------------------------------------------------------------------------------------------------+ | ||
| - | |||
| - | MariaDB [(none)]> | ||
| - | +-----------------------------------------------------------------------------------------------------------------+ | ||
| - | | Grants for www-data@localhost | ||
| - | +-----------------------------------------------------------------------------------------------------------------+ | ||
| - | | GRANT USAGE ON *.* TO ' | ||
| - | | GRANT ALL PRIVILEGES ON `sitedatabase`.* TO ' | ||
| - | +-----------------------------------------------------------------------------------------------------------------+ | ||
| - | |||
| - | MariaDB [(none)]> | ||
| - | +----------------------------------------------------------------------------------------------------------------+ | ||
| - | | Grants for nc-user@localhost | ||
| - | +----------------------------------------------------------------------------------------------------------------+ | ||
| - | | GRANT USAGE ON *.* TO ' | ||
| - | | GRANT ALL PRIVILEGES ON `nextcloud`.* TO ' | ||
| - | +----------------------------------------------------------------------------------------------------------------+ | ||
| - | </ | ||
| - | ===== Grand Users Rights ===== | ||
| - | < | ||
| - | GRANT ALL PRIVILEGES ON `sitedatabase`.* TO ' | ||
| - | GRANT ALL PRIVILEGES ON `nextcloud`.* TO ' | ||
| - | </ | ||
| - | ===== Migrate Databases ===== | ||
| - | Dump the databases on the original server. Better extract them one-by-one so we don't migrate anything unnecessary. To dump as single databases, use the following commands: | ||
| - | # mysqldump -u root -p --all-databases > all_databases.sql | ||
| - | # mysqldump -u [user] -p --opt [database name] > database_name.sql | ||
| - | | ||
| - | # mysqldump -u root -p --opt sitedatabase > sitedatabase_dump.sql | ||
| - | # mysqldump -u root -p --opt nextcloud > nextcloud_dump.sql | ||
| - | |||
| - | Once the dump is completed, you are ready to transfer the databases. But databases need to be created first on target server. | ||
| - | # mysql -u root -p | ||
| - | CREATE DATABASE sitedatabase; | ||
| - | CREATE DATABASE nextcloud; | ||
| - | quit; | ||
| - | Retore the data to the newly creates databases: | ||
| - | # mysql -u [user] -p --all-databases < all_databases.sql | ||
| - | # mysql -u [user] -p newdatabase < DUMP-SITE-DATABASE.sql | ||
| - | | ||
| - | # mysql -u root -p sitedatabase < sitedatabase_dump.sql | ||
| - | # mysql -u root -p nextcloud < nextcloud_dump.sql | ||
linux/mariadb/mariadb-queries.1603446261.txt.gz · Last modified: (external edit)
