Entendi silvestrini. Vou tentar e valeu pela ajuda. Se der certo ou não, posto aqui.

Tranquilo, tem duas comunidades do discord sobre Laravel que eu recomendo você a entrar: Beer and Code, Turma do Tio Jobs. Sempre tem alguém lá pra tirar as dúvidas e ajudar.

https://discord.gg/rCQ63Z3D

https://discord.com/invite/mhyKFgv

Opa silestrini, não deu certo meu caro. Veja no que deu: ```sh lucianogr@lucianogr-Inspiron-15-3520:~/Projects/shortlink/shortlink$ php artisan migrate:fresh Route::get('/', function () { return view('welcome'); }); Route::post('/shorten', [App\Http\Controllers\ShortLinkController::class, 'store'])->name('shorten'); Route::get('{shortCode}', [App\Http\Controllers\ShortLinkController::class, 'show'])->name('shortlink.show'); Illuminate\Database\QueryException Database (shortlinkdb) does not exist. (SQL: PRAGMA foreign_keys = ON;) at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ } +41 vendor frames 42 artisan:37 Illuminate\Foundation\Console\Kernel::handle() lucianogr@lucianogr-Inspiron-15-3520:~/Projects/shortlink/shortlink$ php artisan migrate Route::get('/', function () { return view('welcome'); }); Route::post('/shorten', [App\Http\Controllers\ShortLinkController::class, 'store'])->name('shorten'); Route::get('{shortCode}', [App\Http\Controllers\ShortLinkController::class, 'show'])->name('shortlink.show'); Illuminate\Database\QueryException Database (shortlinkdb) does not exist. (SQL: PRAGMA foreign_keys = ON;) at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ } +35 vendor frames 36 artisan:37 Illuminate\Foundation\Console\Kernel::handle() lucianogr@lucianogr-Inspiron-15-3520:~/Projects/shortlink/shortlink$ ``` O ,env mudei assim e salvei. ``` DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=shortlinkdb DB_USERNAME=root DB_PASSWORD=5577azcD@# ```
Sim, mas viu como mudou o erro, antes era problema com a senha, agora tá falando que o banco não existe. Isso vai se resolver assim que você comentar todas essas linhas que começam com DB, com exceção da primeira sqlite. Quando se usa SQLite, não se define nome do banco, porta, usuário e senha, pois cada arquivo .sqlite é um banco. É só comentar como eu disse no comentário anterior e já vai funcionar bem. Assim: ```php DB_CONNECTION=sqlite #DB_HOST=127.0.0.1 #DB_PORT=3306 #DB_DATABASE=sua_base #DB_USERNAME=root #DB_PASSWORD=admin ```
Consegui. Consegui realizar. veja: lucianogr@lucianogr-Inspiron-15-3520:~/Projects/shortlink/shortlink$ php artisan migrate Route::get('/', function () { return view('welcome'); }); Route::post('/shorten', [App\Http\Controllers\ShortLinkController::class, 'store'])->name('shorten'); Route::get('{shortCode}', [App\Http\Controllers\ShortLinkController::class, 'show'])->name('shortlink.show'); Nothing to migrate. Além do SQLite, ainda estava dando erro no Apache pois o NGinx também estava instalado (fui eu mesmo que instalei os dois porque se um der erro, utilizo o outro servidor). Desinstalei o Nginx para tirar o conflito, ele estava sendo carregado na porta 80 e aí iniciei o Apache. O ambiente é desenvolvimento sim. Cara muito obrigado fiz como você indicou e deu certo. Vivendo e aprendendo.
Laravel exige uma configuração um pouco mais chatinha de Nginx, [aqui está o tutorial de como fazer](https://laravel.com/docs/11.x/deployment#nginx), mas uso apache também por me atender bem. No caso você não precisava desinstalar, era só desabilitar com o comando `sudo systemctl disable nginx`, mas ok. Ao invés de fazer ```php Route::post('/shorten', [App\Http\Controllers\ShortLinkController::class, 'store'])->name('shorten'); Route::get('{shortCode}', [App\Http\Controllers\ShortLinkController::class, 'show'])->name('shortlink.show'); ``` Você pode simplismente [agrupar as rotas que usam o mesmo controller](https://laravel.com/docs/11.x/routing#route-group-controllers), assim: ```php Route::controller(ShortLinkController::class)->group(function(){ Route::post('/shorten', 'store')->name('shorten'); Route::get('{shortCode}', 'show')->name('shortlink.show'); }); ``` Dá pra melhorar ainda mais com [resource controller](https://laravel.com/docs/11.x/controllers#resource-controllers) e [route model binding](https://laravel.com/docs/11.x/routing#route-model-binding)...
Na questão do seu mysql, como acredito que esse banco é local para desenvolvimento, recomendo deixar uma senha fácil como admin, por exemplo. Você pode alterá-la com esses comandos abaixo. - Acessar o banco de dados como root: `sudo su root -c mysql` - Dentro da linha de comando do mysql, alterar senha do usuário para admin: `alter user 'root'@'localhost' identified by 'admin';` Pronto, agora é só testar.