Moodle 3.3.1 fresh install - Barracuda file format issue - installation

I am new to moodle and trying to install moodle 3.3.1 on my windows system, but after some steps it is showing some errors.
mysql_full_unicode_support#File_format: Your database has tables using Antelope as the file format. Full UTF-8 support in MySQL and MariaDB requires the Barracuda file format. Please convert the tables to the Barracuda file format.
mysql_full_unicode_support#Large_prefix: For full support of UTF-8 both MySQL and MariaDB require you to change your MySQL setting 'innodb_large_prefix' to 'ON'. See the documentation for further details.
site not https: It has been detected that your site is not secured using HTTPS. It is strongly recommended to migrate your site to HTTPS for increased security and improved integration with other systems.
please help me to resolve these errors. i am trying to install moodle on my windows system using xampp server. (localhost)

You seem to be having 3 problems
1. Your DB tables are in an earlier format and needs to be upgraded to Barracuda
Moodle created an easy fix for the first problem, before going ahead with the upgrade, you can run the following script from your server, it will upgrade the problematic tables to the Barracuda format
The following command will give you the list of tables that needs to be updated
$ php /path/to/moodle/admin/cli/mysql_compressed_rows.php --list
Then run the fix
$ php /path/to/moodle/admin/cli/mysql_compressed_rows.php --fix
The following link will give you the steps and guide you through the update, the above scripts are from that link
https://docs.moodle.org/28/en/Administration_via_command_line#Converting_InnoDB_tables_to_Barracuda
2. You are having Unicode problems
As of Moodle 3.2, utf8mb4 is used, some changes are required, these answers have been provided before but here they are just in case.
You will first need to edit your my.cnf file and add the following:
[client]
default-character-set = utf8mb4
[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake
[mysql]
default-character-set = utf8mb4
Restart your MySQL service and run the following script:
$ php /path/to/moodle/admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci
Then modify your config.php file:
$CFG->dboptions = array(
…
'dbcollation' => 'utf8mb4_unicode_ci',
…
);
The documentation can be found at the following location:
https://docs.moodle.org/32/en/MySQL_full_unicode_support
3. Your site is not SSL
To make your site SSL you will need to get a SSL certificate from a trusted store such as entrust.

First search result in Google for the error message + "Moodle":
https://docs.moodle.org/33/en/MySQL_full_unicode_support

This answer assumes that you are trying to fix the error on a local installation using xampp.
This is what I did:
first
if you are using xampp on windows, then on your xampp control panel, locate the MYSQL config button and click to see the my.ini option, this is what is called my.cnf on other platforms.
Second
Copy the following text into the my.ini file.
[client]
default-character-set = utf8mb4
[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake
[mysql]
default-character-set = utf8mb4
Third
restart the MYSQL and the error is gone!

Related

Accessed FTP and MYSQL 8.1 for an old sql server caused site to crash [duplicate]

I am using php mysqli_connect for login to a MySQL database (all on localhost)
<?php
//DEFINE ('DB_USER', 'user2');
//DEFINE ('DB_PASSWORD', 'pass2');
DEFINE ('DB_USER', 'user1');
DEFINE ('DB_PASSWORD', 'pass1');
DEFINE ('DB_HOST', '127.0.0.1');
DEFINE ('DB_NAME', 'dbname');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if(!$dbc){
die('error connecting to database');
}
?>
this is the mysql.user table:
MySQL Server ini File:
[mysqld]
# The default authentication plugin to be used when connecting to the server
default_authentication_plugin=caching_sha2_password
#default_authentication_plugin=mysql_native_password
with caching_sha2_password in the MySQL Server ini file, it's not possible at all to login with user1 or user2;
error: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in...
with mysql_native_password in the MySQL Server ini file, it's possible to login with user1, but with user2, same error;
how can I login using caching_sha2_password on the mySql Server?
I solve this by SQL command:
ALTER USER 'mysqlUsername'#'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
which is referenced by https://dev.mysql.com/doc/refman/8.0/en/alter-user.html
if you are creating new user
CREATE USER 'jeffrey'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
which is referenced by https://dev.mysql.com/doc/refman/8.0/en/create-user.html
this works for me
As of PHP 7.4, this is no longer an issue. Support for caching_sha2 authentication method has been added to mysqlnd.
Currently, PHP mysqli extension do not support new caching_sha2 authentication feature.
You have to wait until they release an update.
Check related post from MySQL developers: https://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/
They didn't mention PDO, maybe you should try to connect with PDO.
ALTER USER 'mysqlUsername'#'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
Remove quotes (') after ALTER USER and keep quote (') after mysql_native_password BY
It is working for me also.
If you're on Windows and it's not possible to use caching_sha2_password at all, you can do the following:
rerun the MySQL Installer
select "Reconfigure" next to MySQL Server (the top item)
click "Next" until you get to "Authentication Method"
change "Use Strong Password Encryption for Authentication (RECOMMENDED)" to "Use Legacy Authentication Method (Retain MySQL 5.X Compatibility)
click "Next"
enter your Root Account Password in Accounts and Roles, and click "Check"
click "Next"
keep clicking "Next" until you get to "Apply Configuration"
click "Execute"
The Installer will make all the configuration changes needed for you.
Like many many people, I have had the same problem. Although the user is set to use mysql_native_password, and I can connect from the command line, the only way I could get mysqli() to connect is to add
default-authentication-plugin=mysql_native_password
to the [mysqld] section of, in my setup on ubuntu 19.10, /etc/mysql/mysql.conf.d/mysqld.cnf
It's working for me (PHP 5.6 + PDO / MySQL Server 8.0 / Windows 7 64bits)
Edit the file C:\ProgramData\MySQL\MySQL Server 8.0\my.ini:
default_authentication_plugin=mysql_native_password
Reset MySQL service on Windows, and in the MySQL Shell...
ALTER USER my_user#'%' IDENTIFIED WITH mysql_native_password BY 'password';
I ran the following command
ALTER USER 'root' # 'localhost' identified with mysql_native_password BY 'root123'; in the command line and finally restart MySQL in local services.
If you're on a Mac, here's how to fix it. This is after tons of trial and error. Hope this helps others..
Debugging:
$mysql --verbose --help | grep my.cnf
$ which mysql
/usr/local/bin/mysql
Resolution:
nano /usr/local/etc/my.cnf
Add: default-authentication-plugin=mysql_native_password
-------
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
default-authentication-plugin=mysql_native_password
------
Finally Run: brew services restart mysql
Now you can upgrade to PHP7.4 and MySQL will go with caching_sha2_password by default, so default MySQL installation will work with mysqli_connect No configuration required.
I tried this in Ubuntu 18.04
and is the only solution that worked for me:
ALTER USER my_user#'%' IDENTIFIED WITH mysql_native_password BY 'password';
If you have not yet already changed your MySQL default authentication plugin, you can do so by:
Log in as root to MySQL
Run the following SQL command:
a. if you are running MySQL in a different server:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password
BY 'password';
b. if you are running MySQL in a different server:
ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password
BY 'password';
I am using laravel 5.8 and having MAMP server got this error resolved by adding DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock in .env file like below
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=dbname
DB_USERNAME=root
DB_PASSWORD=root
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
In my case when I was using WAMP server I fixed it using following
Note the port in mySQL's "my.ini" file. In my case it was changed to 3308 when I was switching b/w MariaDB and MySQL DB.
Use the port number when you create mysqli object.
Using the above steps I was able to run the program successfully.
phpMyAdmin GUI way
Note: This method may not work if you have the problem with root user account.
Login to phpMyAdmin as root.
Switch to "User Accounts" tab.
Select the username you get error with.
From the top buttons, switch to "Login Information" section.
In "Login Information" box, change "Authentication plugin" from "Caching sha2 authentication" to "Native MySQL authentication". Also, you must fill in other required fields, obviously, including username and password.
Save it by clicking on the "Go" button at the bottom.
Return back to terminal and enjoy. :)
In my case, i'm using PHP Symfony framework and it's a silly mistake.
The database credential was wrong in paramers.yml.
After changing the credentials accordingly the problem was gone.
In Digital Ocean Managed Mysql, we have an option to change encryption, you can change to legacy and it'll work ok.
I think it is not useful to configure the mysql server without caching_sha2_password encryption, we have to find a way to publish, send or obtain secure information through the network. As you see in the code below I dont use variable $db_name, and Im using a user in mysql server with standar configuration password.
Just create a Standar user password and config all privilages. it works, but how i said without segurity.
<?php
$db_name="db";
$mysql_username="root";
$mysql_password="****";
$server_name="localhost";
$conn=mysqli_connect($server_name,$mysql_username,$mysql_password);
if ($conn) {
echo "connetion success";
}
else{
echo mysqli_error($conn);
}
?>

Sqlsrv pdo driver extension works in tinker but not in web app

I'm running Laravel with homestead and virtualbox. Via the command line, I have downloaded both the pdo_sql and sqlsrv driver extensions for php 7 and added them to my php.ini file. Using php artisan tinker, I am able to read/write to my table data just fine, but when I try to access any of the data in the actual web app I get these exceptions.
PDOException in Connector.php line 68: could not find driver
QueryException in Connection.php line 647:
could not find driver (SQL: select top 1 * from [User] where [email] = blah#email.com)
For some reason Laravel isnt seeing my drivers but tinker is. Any help from you guys on this would be much appreciated.
Turns out tinker and laravel use different php.ini files. Though I added the sqlsrv and pdo_sqlsrv extension to the tinker ini file located in (/etc/php/x.x/cli/php.ini). I hadn't changed the php.ini file laravel uses which is located in (/etc/php/x.x/fpm/php.ini)
After adding those extensions to the correct file and restarting my system, everything worked great. Hopes this helps someone!
If you have SELinux enabled, this might be the problem.
Check by disabling it
$ setenforce 0
If it starts working, permit apache or php-fpm to connect to this port
$ semanage port -m -t http_port_t -p tcp 1433
then enable SELinux and check that it works
$ setenforce 1

I cannot see utf8mb4 characters from my database with cmd on windows

This is how I connect to my database on my Windows cmd: mysql -u mydb -h myip -p.
It has always worked since I tried to swap my utf8 database to utf8mb4. The changes I apply with php or java work fine and I can see those characters correctly when loading from php, java or phpmyadmin but not on my cmd.
I have tried adding --default-character-set=utf8 and --default-character-set=utf8mb4 to the cmd connection with no succeed. It is curious, by the way, that if I run a simple sentence like SELECT '☺'; it shows that character correctly.
Am I missing something?
Based on the findings of danibg in the end of our brainstorming session, he has found this link which describes that this is a MySQL bug which was applicable to 5.5, used by the op and apparently this was fixed for MySQL 5.6+
We tested 5.6 version of client against 5.5 version of server,
especially with respect to non ANSI characters. The 5.6 client worked
as expected and the issue mentioned in this bug was also fixed.
As a result, the solution is as follows:
create a backup and store at least 2 copies
uninstall MySQL 5.5
install MySQL 5.6+
import the copy
do a lot of tests

unixODBC Data source name not found, and no default driver specified

I'm trying to connect to a db2 server from my Laravel application. Since Laravel doesn't support db2 out of the box, I tried using this package https://github.com/cooperl22/laravel-db2, which requires me to install odbc driver.
So far, I've been able to install odbc using the following command:
apt-get install php-odbc
However, it seems like my /etc/odbc.ini and /etc/odbcinst.ini configuration are still wrong. and here's the full error message when I tried to run php artisan migrate:
[PDOException]
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default
driver specified
Here's my /etc/odbc.ini:
[db2]
Description=DB2 Server
Driver=db2
Database=mydb
and here's my /etc/odbcisnt.ini:
[db2]
Description = DB2 database access
Driver = /opt/ibm/db2/V10.5/lib64/libdb2.so
FileUsage = 1
DontDLClose = 1
Ensure that your environment variables are set correctly. As shown on this link, make sure the following is set:
export DB2INSTANCE=db2inst1
isql -v sample db2inst1 ibmdb2
Exerpt from the unixodbc.org page I linked to above:
Then when it comes to connecting, you MUST have the environment
variable DB2INSTANCE set to a vaild db2 instance, so for instance to
connect with isql
Both of your config files look correct to me. (The isql part was just an example to test connectivity.)

Heroku Database Connection Properties

I'm trying to perform a relatively trivial task: I want to connect to a Heroku database. I have created the database and have been issued credentials from the Heroku site. However, when I try to connect to this database using anything besides the terminal 'heroku' command line client, I get fatal errors or cannot connect errors.
The two tools that I tried to connect with outside of the Heroku terminal application are: Navicat and IntelliJ.
The error that I receive in Navicat when trying to connect to the database is:
could not connect to server: Host is down
Is the server running on host "ec2-107-21-112-215.compute-1.amazonaws.com" and accepting
TCP/IP connections on port 5432?
My connection settings are as follows:
Connection Name Heroku Dev Test
Host Name/IP Address ec2-107-21-112-215.compute-1.amazonaws.com
Port 5432
Navicat doesn't even seem to be making an attempt to connect to that hostname.
When I try to connect with IntelliJ, using the full credentials, I get the following error:
java.sql.SQLException: FATAL: no pg_hba.conf entry for host "75.168.4.146", user "rphbqggxeokuxl", database "dc008iqk0rq4j5", SSL off
Again, I'm using the credentials that the Heroku application provides me with when accessing my database on their website.
Has anyone ran into this Heroku connection issue before?
I also had the issue with the FATAL: no pg_hba.conf entry for host error message.
I solved the connection issue to my Heroku Postgres database by adding the following to my JDBC string: &ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory.
Example
jdbc:postgresql://host:port/database?user=username&password=secret&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
You will need the SSL option only if SSL is enabled for your Postgres database (which is the default).
Hint
If you want to check your database connection properties, then just run the following command with the Heroku Toolbelt: heroku pg:info --app your-heroko-appname (make sure that you have Postgres insalled to run this command in your terminal)
The pg:info command will also tell you that sslmode is set to require.
To test the database connection I recommend SQL Power Architect as it is the tool which I was using to check my solution.
Heroku provides this information for connecting from external sources:
https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress
The second error message indicates PostgreSQL is not configured to accept the connection you're trying to make. Given the information Heroku provides, a good guess is that you're not connecting with SSL. Try to enable that on your connection.
Here are instructions for using SSL with Navicat: http://mirror.navicat.com/manual/online_manual/en/navicat/rv_manual/ClientCert.html.
This may be helpful in configuring Intellij to use SSL: https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#connecting-to-a-database-remotely.
IntelliJ -> Datasources and Drivers
After you've configured the host, database and user details under the General tab switch to the Advanced tab and ensure that you've added the following:
ssl = true
sslfactory = org.postgresql.ssl.NonValidatingFactory
sslmode = require
You may consider setting a ENVIRONMENT CONFIG VARIABLE 'PGSSLMODE' to 'require' via Heroku's web interface or CLI.
Case: Postgres dB set up as a Heroku add-on and attached to app on a Heroku Dyno.
Heroku's instructions unfortunately leave out any mention of how to activate SSL, even though it is required for any dB tier starting with Standard-0 by default.
Follow all of the pg-copy or pg-upgrade steps (preferred approach depends on your version of Postgres) in Heroku instructions; however, before decommissioning the old database (if relevant) -- add the PGSSLMODE environment variable.
The instructions sufficiently cover how to promote the new database (and, consequently set the DATABASE_URL), so no changes/modifications to them should be required.
Wanted to help others who might run into this.
If you're supplying the Username and Password in seperate fields rather than on the command line, you need to use a ? between the database name and ssl=true and discard the first &
jdbc:postgresql://host:port/database?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
That's the command line that finally allowed me to connect to a PostgreSQL database using SQL Power Architect
For those who might be using Spring Boot and having the configuration provided through the DATABASE_URL environment property (not system property), the suffix can be added to the property:
?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
and passed through with a slight modification to the config bean:
#Bean
public BasicDataSource dataSource() throws URISyntaxException {
URI dbUri = new URI(System.getenv("DATABASE_URL"));
String username = dbUri.getUserInfo().split(":")[0];
String password = dbUri.getUserInfo().split(":")[1];
StringBuilder dbUrl = new StringBuilder(128);
dbUrl.append("jdbc:postgresql://")
.append(dbUri.getHost()).append(":")
.append(dbUri.getPort())
.append(dbUri.getPath());
String query = dbUri.getQuery();
if (null != query && !query.isEmpty()) {
dbUrl.append("?").append(query);
}
BasicDataSource basicDataSource = new BasicDataSource();
basicDataSource.setUrl(dbUrl.toString());
basicDataSource.setUsername(username);
basicDataSource.setPassword(password);
return basicDataSource;
}
I'm using node.js and was trying to run my knex migrations for my Heroku app. I tried appending ?sslmode=require to the connection URL but it didn't work. I added ?ssl=true instead and now it works perfectly.
Here's an example Heroku PostgreSQL connection URL that works:
postgres://user:password#ec2-12-34-56-78.compute-99.amazonaws.com:port/databasename?ssl=true
Add or edit the following line in your postgresql.conf file :
listen_addresses = '*'
Add the following line as the first line of pg_hba.conf. It allows access to all databases for all users with an encrypted password:
TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 0.0.0.0/0 md5
Restart postgresql service:
net stop postgresql-9.0 & net start postgresql-9.0
(version should be based on your installation) -- On windows (run cmd as an administrator).
sudo service start postgresql -- On linux (or according to your linux distribution.)
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});

Resources