Failing to connect to database |
02-21-2018, 01:57 PM
(This post was last modified: 02-21-2018, 03:02 PM by ciadmin. Edit Reason: redacted password )
Just started using CodeIgniter today following the tutorial on the site and ran into a problem with setting up the database. Looked around various other forums and sites for a couple hours to no avail of how to fix the problem. My setup is a local MySQL database, CodeIgniter and XAMPP.
The exact error message is: Quote:Message: mysqli::real_connect(): (HY000/1045): Access denied for user 'unityAdmin'@localhost (using password: YES) Now I know the credentials themselves are working fine since I can manually connect to the database via command line or Sequel Pro with the credentials that are in the database.php config file which looks like: PHP Code: $db['default'] = array( Including the MVC code here for reference. Model: PHP Code: <?php Controller: PHP Code: <?php Index View: PHP Code: <h2><?php echo $title; ?></h2> Specific Post: PHP Code: <?php
Check what is the host of your MySQL user account.
If you have only one account like 'unityAdmin'@'127.0.0.1' this could be the issue. Create other account with privileges for 'unityAdmin'@localhost or update to 'unityAdmin'@'%'. Or, just update from 'localhost' to '127.0.0.1' in the database.php.
(02-21-2018, 10:58 PM)natanfelles Wrote: Check what is the host of your MySQL user account. Thanks for the suggestions I will play with this now and get back to you. The user isn't the only user for the mysql account but it is the only user for the database I'm trying to use and setting the host to 127.0.0.1 in the database.php file changes nothing for me. (02-21-2018, 11:00 PM)natanfelles Wrote: and $active_group = 'default'; This is already set as default so I didn't include it in the post sorry.
SOLVED
Issue was with using XAMPP. XAMPP only expects to see user = root and password = ' ' so anything else isn't accepted even though I had created a new user on phpmyadmin...
HOW TO RESET MySQL PASSWORD phpMyAdmin:
If the MySQL Server is running stop it! 1) Open the file my.ini - in C:\xampp\mysql\bin\my.ini 2) Under: # The MySQL server [mysqld] 3) add: skip-grant-tables 4) Start the MySQL Server and run this SQL query in phpMyAdmin. UPDATE mysql.user SET Password=PASSWORD('Your-Password') WHERE User='root'; FLUSH PRIVILEGES; 5) Close phpMyAdmin and Stop the MySQL Server 6) Open the file my.ini - in C:\xampp\mysql\bin\my.ini 7) Remark out the line skip-grant-tables - #skip-grant-tables 8) Re-start the MySQL Server and you should now be able to login with the new password. For the command line version see this article: B.5.3.2 How to Reset the Root Password What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Update: 03-03-2021
XAMPP - Make sure MySQL is not running. Change User and Password. Code: // Shell from the XAMPP Control Panel for Windows What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Please refer https://codeigniter.com/userguide3/database/index.html if you've downloaded codeigniter 3 and this https://codeigniter.com/user_guide/database/index.html# if you're using codeigniter 4. It looks like you've CI4 and the code in the Model is for CI3.
Do the following using XAMPP
In the XAMPP Control Panel on the right side. Code: // Shell from Control Panel It thinks the password is yes. Change the above root to your user name. Change the above your_password to yours that works. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |