Valet Linux+

Database

Valet Linux+ installs MySQL from your distribution's repositories. Prefer MariaDB? Install with:

bash
valet install --mariadb

If MySQL or MariaDB is already installed, Valet uses the existing server.

Database user

During installation Valet creates a valet database user with all privileges and asks you to set its password. The credentials are stored in ~/.config/valet/config.json and used by every db:* command.

To (re)configure the credentials Valet uses — for example with an existing user:

bash
valet db:configure
valet db:configure --force   # overwrite credentials that are already stored

Use these credentials in your applications:

dotenv
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USERNAME=valet
DB_PASSWORD=<your password>

Listing databases

bash
valet db:list

Creating a database

bash
valet db:create <name>

When no name is given, the current directory name is used:

bash
valet db:create

Dropping a database

bash
valet db:drop <name>

Valet asks for confirmation; skip it with -y / --yes. When no name is given, the current directory name is used.

Resetting a database

Drops and re-creates a database:

bash
valet db:reset <name>

Valet asks for confirmation; skip it with -y / --yes. When no name is given, the current directory name is used.

Exporting a database

bash
valet db:export <name>

When no name is given, the current directory name is used. Exports are gzipped (.sql.gz) by default; export a plain SQL file with --sql:

bash
valet db:export <name> --sql

Importing a database

bash
valet db:import <name> <file>

Both the database name and the file are required. The database is created when it does not exist; when it already exists, Valet asks for confirmation before importing into it. Both plain .sql files and gzipped .sql.gz exports are supported.