Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rostenkowski/cheats
PostgreSQL / MySQL / Cheatsheet
https://github.com/rostenkowski/cheats
cheatsheet database-management export import mysql postgresql
Last synced: 26 days ago
JSON representation
PostgreSQL / MySQL / Cheatsheet
- Host: GitHub
- URL: https://github.com/rostenkowski/cheats
- Owner: rostenkowski
- Created: 2012-05-23T12:35:43.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T19:15:45.000Z (over 7 years ago)
- Last Synced: 2024-11-07T02:04:40.560Z (3 months ago)
- Topics: cheatsheet, database-management, export, import, mysql, postgresql
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PostgreSQL
```bash
sudo su postgres
psql
```
```sql
CREATE USER user WITH PASSWORD 'password' LOGIN;
CREATE DATABASE project;
GRANT ALL ON DATABASE project TO user;
```
## Export
```bash
pg_dump database > database.sql
```
## Import
```bash
psql -d database < file.sql
```# MySQL
```bash
mysql -u root -p
```
```sql
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE project;
GRANT ALL PRIVILEGES ON project.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
```
## Export
```bash
mysqldump -uroot -p database >> database.sql
```
## Import
```bash
mysql -uroot -p -Ddatabase < database.sql
```
## Reset root password
```bash
sudo dpkg-reconfigure mysql-server
```