Failing to connect to database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: Failing to connect to database (/showthread.php?tid=70106) |
Failing to connect to database - IcyGrey - 02-21-2018 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 RE: Failing to connect to database - natanfelles - 02-21-2018 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. RE: Failing to connect to database - natanfelles - 02-21-2018 and $active_group = 'default'; RE: Failing to connect to database - IcyGrey - 02-22-2018 (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. RE: Failing to connect to database - IcyGrey - 02-22-2018 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... RE: Failing to connect to database - InsiteFX - 02-22-2018 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 RE: Failing to connect to database - adhzim - 03-03-2021 (02-22-2018, 04:35 AM)IcyGrey Wrote: SOLVEDthanks man! much appreciated RE: Failing to connect to database - InsiteFX - 03-03-2021 Update: 03-03-2021 XAMPP - Make sure MySQL is not running. Change User and Password. Code: // Shell from the XAMPP Control Panel for Windows RE: Failing to connect to database - hooper - 03-23-2021 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. RE: Failing to connect to database - InsiteFX - 03-23-2021 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. |