Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter\Database\Exceptions\DatabaseException Unable to connect to the database.
#1
Exclamation 
(This post was last modified: 06-11-2023, 07:52 PM by shiro.)

[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']I encountered an error while working with CodeIgniter and attempting to establish a database connection. The error message states:[/font]
[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']"CodeIgniter\Database\Exceptions\DatabaseException: Unable to connect to the database. Main connection [MySQLi]: No such file or directory."[/font]
[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']I have already checked that XAMPP is up and running, and I can successfully access phpMyAdmin. However, CodeIgniter seems to be unable to connect to the database.[/font]
[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']I have configured the database settings in my .env file as follows:[/font]

database.default.hostname = localhost

database.default.database = db_film

database.default.username = root

database.default.password =

database.default.DBDriver = MySQLi

database.default.DBPrefix =

database.default.port = 3306



[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']The database "db_film" already exists, and the username and password are correct. I have also made sure that the MySQLi extension is enabled in my PHP configuration.[/font]

[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']Is there anything else I need to check or configure to resolve this issue? I would appreciate any assistance or guidance. Thank you.[/font]

[font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']Additional Information:[/font]
  • [font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']Operating System: Linux (Arch Linux)[/font]
  • [font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']XAMPP is running successfully[/font]
  • [font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']PHP version: [insert your PHP version here][/font]
  • [font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']CodeIgniter version: [insert your CodeIgniter version here][/font]
  • [font=Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji']MySQLi extension is enabled[/font]
Reply
#2

Hi shiro,
I guess you just deleted the password in your post here as you wrote you were sure it is correct.
Have you checked the port? Maybe try on port 3307. You could also try additionally to change default hostname to ‘127.0.0.1:3307’
Reply
#3

Code:
// Shell from Control Panel or CMD - change your_password to yours.
cd mysql\bin
mysqladmin --user=root password "your_password"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB