Database
Valet Linux+ installs MySQL from your distribution's repositories. Prefer MariaDB? Install with:
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:
valet db:configure
valet db:configure --force # overwrite credentials that are already stored
Use these credentials in your applications:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USERNAME=valet
DB_PASSWORD=<your password>
Listing databases
valet db:list
Creating a database
valet db:create <name>
When no name is given, the current directory name is used:
valet db:create
Dropping a database
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:
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
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:
valet db:export <name> --sql
Importing a database
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.