Databases
PostgreSQL, MySQL, Redis and friends. 18 commands.
- Import a .sql file into MySQLLoad a database dump or a script into MySQL from the command line.
- psql basics: list tables, describe, switch database and quitThe handful of psql commands everyone needs: show databases and tables, look at a table, move around and get out.
- Install PostgreSQLPostgreSQL installed directly on your machine, running in the background.
- Back up a MySQL databaseSave a whole MySQL database to a .sql file with mysqldump.
- Back up and restore a PostgreSQL databaseSave a whole database to a .sql file with pg_dump, then load it back with psql.
- Change a PostgreSQL user's passwordSet a new password for any PostgreSQL user, including postgres itself.
- Create a Postgres user and databaseA database for your app with its own user, plus the connection string to paste into your .env.
- Export a PostgreSQL query to CSVSave a table or any query's results as a CSV file you can open in a spreadsheet.
- Fix MySQL "Access denied for user 'root'@'localhost'"MySQL rejects the root login. Usually it's the wrong password, or on Ubuntu, root logs in with sudo.
- Fix MySQL "Can't connect to local MySQL server through socket"The MySQL server isn't running, or isn't where the client is looking. Start it, or connect over the network.
- Fix PostgreSQL "Peer authentication failed"On Linux, PostgreSQL checks your system user name. Connect as the matching user, or over localhost with a password.
- Fix PostgreSQL "role does not exist"You're connecting as a user PostgreSQL doesn't know. Create that role, or connect as one that exists.
- Install MongoDBMongoDB Community Server and the mongosh shell, running locally.
- Install MySQLMySQL installed directly on your machine, running in the background and secured.
- Install RedisRedis running locally for caching, queues and sessions.
- Install SQLiteThe tiny database that lives in a single file, with its command-line tool.
- List, create and grant MySQL usersSee who can log in to MySQL, add a user for your app and give it access to one database.
- Start and stop PostgreSQL, MySQL and RedisStart a local database when you need it and stop it to free up memory.