Installing and upgrading help

mysql_Connect error 3.2.1

 
Picture of Mark Fritz
mysql_Connect error 3.2.1
 

I've rebuilt out server using Ubuntu 16.0.4 and migrated our old install from a SLES box.

I'm now unable to log in and get an mysql_connect() error due to that module being depricated in php7 but I cannot find anywhere where it is referenced in my config.

I've tried both mariadb and mysqli in the config.php file but it doesn't make a difference.


Debug trace is:


Exception - Call to undefined function mysql_connect()

More information about this error

Debug info: 
Error code: generalexceptionmessage
Stack trace:
  • line 461 of /lib/adodb/drivers/adodb-mysql.inc.php: Error thrown
  • line 492 of /lib/adodb/drivers/adodb-mysql.inc.php: call to ADODB_mysql->_connect()
  • line 667 of /lib/adodb/adodb.inc.php: call to ADODB_mysql->_nconnect()
  • line 878 of /enrol/database/lib.php: call to ADOConnection->Connect()
  • line 164 of /enrol/database/lib.php: call to enrol_database_plugin->db_init()
  • line 239 of /lib/enrollib.php: call to enrol_database_plugin->sync_user_enrolments()
  • line 478 of /lib/classes/session/manager.php: call to enrol_check_plugins()
  • line 4410 of /lib/moodlelib.php: call to core\session\manager::login_user()
  • line 195 of /login/index.php: call to complete_user_login()

 
Average of ratings: -
Picture of Ken Task
Re: mysql_Connect error 3.2.1
Particularly helpful Moodlers

Don't think using mariadb on a MySQL DB will work.   Stick wtih mysqli.

Is your login a manual account? (admin level).   Happen to remember what your account ID number was?

Did your site, under SuSE, use the DB for sessions? (SuSE site still up? check it's settings)

Assuming you can connect to the DB via command line with the DB user and DB password you have in the config.php file and that the import of the SQL dump from the SuSE site was completed without error:

Things to try:

Edit config.php file and add:

$CFG->dbsessions=0;

$CFG->siteadmins='2,[YOURACCOUNTIDNUMBER'';

ID 2 was the original/initially setup admin user that might still have 'admin' (that was default) as the username.

If you can query the DB from the command line one could use this query to find a row/records for a user with a known username (login)

mysql> select id,auth,email from mdl_user where username = '[YOURUSERNAME/login]';
Then use the ID number in the siteadmins line of config.php file.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Mark Fritz
Re: mysql_Connect error 3.2.1
 

Hi Ken,

I reverted back to mysqli in the config.php with the same result.

As far as I can tell the database connection works as the website shows the correct theme and site customised text from the database. I can't figure out what might be overriding the mysqli directlive which I've been using since version 2.x.

Sessions are stored in the database, I actually cloned the SLES virtual machine to a new one in vmware and installed ubuntu onto the primary partition in the clone.

I then mounted the existing Moodle installation from the clone after installing all the php packages and extras listed in the wiki for 16.0.4.1 then did the upgrade.

I've gone back to the original SLES clone, restored last night database backup and will have to re-schedule a 3.2 upgrade to the next holiday period in April.

 
Average of ratings: -
Picture of Ken Task
Re: mysql_Connect error 3.2.1
Particularly helpful Moodlers

Huh?

"...cloned the SLES virtual machine to a new one in vmware and installed ubuntu onto the primary partition in the clone."

So VMWare, guest OS SLES and in that Ubuntu!!!!

'then mounted the existing Moodle installation from the clone'

Lost me there.  What does that mean?

What shows to a web browser could be cached.   Try connecting to the DB from command line client.

'spirit of sharing', Ken

 
Average of ratings: -
Andrew Normore
Re: mysql_Connect error 3.2.1
 

Hello, I have your fix. You will be very happy smile

Turns out, you have config.php set to use mysqli correctly, BUT the Moodle driver doesn't work correctly to select mysqli.

It still loads mysql driver to talk to your database. Because you're on PHP7, mysql_connect() has been removed from PHP.

Here's the fix:

https://github.com/moodle/moodle/compare/master...AndyNormore:patch-1

It's one simple link of code not working. I'm not sure if this is Moodle officially approved, but it will certainly limp you by. The bug is present in Moodle 3.3.1 and 3.3.2 I can confirm, not sure about others or when this bug is introduced.

 
Average of ratings: -
Picture of Dan Marsden
Re: mysql_Connect error 3.2.1
Core developersMoodle Course Creator Certificate holdersParticularly helpful MoodlersPlugin developersPlugins guardiansTestersTranslators

um - not quite... the debug log shows this is coming from /enrol/database/lib.php - which is the external enrolment database connection - not the connection to the Moodle database.

you need to go to admin > plugins > enrolments > External Database and change the settings on that page to use "mysqli" instead of "mysql" when connecting to your external database enrolment plugin. (not the setting in config.php)

 
Average of ratings: Useful (1)
Andrew Normore
Re: mysql_Connect error 3.2.1
 

Aha! That would certainly explain the problem!

I'll try this tomorrow and report back.

 
Average of ratings: -
Picture of Gisele Brugger
Re: mysql_Connect error 3.2.1
 

Hello

I had the same problem

Moodle : 3.4
php : 7
mysql: 5.7.20

distro: debian 9

erro mysql connect

but I did not have authentication and in enroll via database 

when i change /enrol/database/lib.php

- $extdb = ADONewConnection($this->get_config('dbtype'));
+ $extdb = ADONewConnection($CFG->dbtype);


worked perfect


Thank you Andrew smile

 
Average of ratings: -
Andrew Normore
Re: mysql_Connect error 3.2.1
 

Turns out this is not the correct fix, and you need to actually go in to Moodle and configure the enrolment plugin itself... I forget how I did it now, but the code is behaving as expected.

 
Average of ratings: -
Picture of mersad web
Re: mysql_Connect error 3.2.1
 

Aha! That would certainly explain the problem!

I'll try this tomorrow and report back.


 
Average of ratings: -