OctoberCMS Builder MySQL Invalid default value for the integer column - mysql

I built an OctoberCMS site on a local VirtualBox LAMP server and moved it and the MySQL database to A2 Shared Hosting.
Error
The live site is working fine, but when I use the Builder plugin to add a new database column and save, I get the error:
Invalid default value for the integer column 'sort_order'. The allowed formats are '10', '-10'.
But the value is 10.
Servers
My Local VirtualBox Server is running MySQL 5.7.29-0ubuntu0.18.04.1.
The A2 Hosting Server is running MySQL 10.3.22-MariaDB-cll-lve.
Database Connection
The database.php config file looks like this, with the database name, username, and password filled in.
'mysql' => [
'driver' => 'mysql',
'engine' => 'InnoDB',
'host' => 'localhost',
'port' => 3306,
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'varcharmax' => 191,
],
Question
Why does saving the new column not work?
Does it have something to do with MySQL on the local server and MariaDB on the A2 server?

Related

Virtualmin Database: connection timed out

I installed virtualmin on a VM instance using google compute engine. I have set up 1 domain and 1 subdomain. On the subdomain i created a database (flexijobs) and added the Drupal tables. Everything works fine except the connection to the database. On loading the drupal index page i get this error:
PDOException: SQLSTATE[HY000] [2002] Connection timed out
My guess is that the settings are not correct, so in a virtualmin setup, what should i use here, where can i set the password/user, what port should i use, what is the host?
$databases['default']['default'] = array (
'database' => 'flexijobs',
'username' => 'someUsername',
'password' => 'somePassword',
'prefix' => '',
'host' => 'db.somedomain.com',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
Create a new database through Webmin > Servers > MariaDB Database Server
Note the name, username and password for the database you just made and modify the configuration file to include the information for your database.
The host field should be set to localhost
$databases['default']['default'] = array (
'database' => 'database_name',
'username' => 'db_username',
'password' => 'db_password',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);

Laravel 8 - How to solve Connection timed out while using remote MYSQL database?

In one of my Laravel 8 applications, I need to use two databases where one is a remote database. In my local development environment, the remote database is working fine (I can fetch data), but the problem arises only when I host the application in production. Every time it responds connection time out even for a simple query like SELECT * FROM users WHERE email = 'my_target_email_address'
Here is my .env file code:
# Local DB
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=bint_gt
DB_USERNAME=root
DB_PASSWORD=
# REMOTE DB
REMOTE_DB_CONNECTION=mysql
REMOTE_DB_HOST=REMOTE_DB_HOST
REMOTE_DB_PORT=3306
REMOTE_DB_DATABASE=REMOTE_DB
REMOTE_DB_USERNAME=REMOTE_DB_USER
REMOTE_DB_PASSWORD=REMOTE_DB_PASSWORD
Here is the updated code for the remote database in the config/database.php file:
'remote_mysql' => [
'driver' => 'mysql',
'url' => env('MFO_DATABASE_URL'),
'host' => env('MFO_DB_HOST'),
'port' => env('MFO_DB_PORT', '3306'),
'database' => env('MFO_DB_DATABASE', 'forge'),
'username' => env('MFO_DB_USERNAME', 'forge'),
'password' => env('MFO_DB_PASSWORD', ''),
'unix_socket' => env('MFO_DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
Finally, run the following MySQL query to fetch data:
$userEmail = Auth::user()->email;
$userInfo = DB::connection('remote_mysql')->select("SELECT * FROM users WHERE user_email='$userEmail'");
if( !empty($userInfo) ) {
$uid = $userInfo[0]->uid;
# do rest of the work
} else {
# return JSON response of user not found
}
Everything works fine in my local development environment (XAMPP), although the speed is a little bit slow, it does not work on the production server.
N.B: I am using Plesk rather cPanel.
Can anyone help me to figure out how to fix the problem?

Laravel 5 and remote mysql not working on production

In my local environment I have working a secondary remote mysql connection specified in config/database.php without any problems:
# Secondary database connection
'mysql_remote' => [
'driver' => 'mysql',
'host' => env('DB_HOST_2', 'cherokee.websitewelcome.com'),
'port' => env('DB_PORT_2', '3306'),
'database' => env('DB_DATABASE_2', 'dbname'),
'username' => env('DB_USERNAME_2', 'dbusr'),
'password' => env('DB_PASSWORD_2', 'dbpass'),
'unix_socket' => env('DB_SOCKET_2', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
But when I run this on production server with the exact same database file I get the following error, is like the remote host (cherokee.websitewelcome.com) is not used and replace it with local server host (eu01.server.plus)
SQLSTATE[HY000] [1045] Access denied for user 'dbusr'#'eu01.server.plus' (using password: YES) (SQL: select ...)
Any ideas?
Solved by adding eu01.server.plus to authorized hosts on remote mysql server. Initially I was adding the IP and not hostname.

Laravel 5.1 - Connecting to MySQL Database (MAMP)

There are topics online that are discussing this problem however, I couldn't find any tidy explanation of the problem or any solid answers for the question. What I am trying to achieve is connecting Laravel 5.1 to MySQL Database of MAMP.
In my config>app.php:
'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost:8889',
'database' => 'test',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'prefix' => '',
'strict' => false,
],
In my .env:
DB_HOST=localhost
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=root
I also have .env.example: (which I believe has no functionality)
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
I also have create_users_table.php and create_password_resets_table.php in my database>migrations (even though I did not run any migration:make)
MAMP is directing and running the server successfully as it loads the project on localhost.
Here is my MAMP settings:
And the test database is created (with tables in it which I have previously created and used in my other projects, not Laravel.)
Even though everything seems correct to me, when trying to submit Auth form, I am getting this error:
PDOException in Connector.php line 50:
could not find driver
in Connector.php line 50
at PDO->__construct ('mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=test', 'root', 'root', array('0', '2', '0', false, false)) in Connector.php line 50
at Connector->createConnection('mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=test', array('driver' => 'mysql', 'host' => 'localhost:8889', 'database' => 'test', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 22
and so on...
On mac or unix you have to include the socket path in the configuration database.php file
i.e 'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
It was pretty simple for me, I added :8889 to the localhost in the .env file.
DB_HOST=localhost:8889
This is because in the MAMP preferences, :8889 is the default port.
The most important thing for me was defining the UNIX socket. Because I have another MYSQL on my machine - Laravel was trying to connect to a database in that MYSQL process.
Defining the UNIX for the MAMP database to be used worked perfectly. Try adding this to your MYSQL configuration in database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
As far as I am concerned it doesn't make any sense to set in database.php as many of them suggested.
Since this change would be mostly required in the development mode. So the proper way of setting the unix_socket is as below
file: .env
DB_SOCKET='/Applications/MAMP/tmp/mysql/mysql.sock'
By doing the above way already .env is included in .gitignore and won't create any other problem while your project is remotely deployed.
NOTE: I have tested this setting in Laravel 5.7 and above versions
Found my answer. Here is a way to fix it:
Start MAMP
On the top left, go to "MAMP" -> "Preferences"
Go to the "PHP" tab
Tick PHP 5.5.17 (or whatever you have) instead of the one which is ticked by default (5.6.1 -> 5.5.17 with he latest version of MAMP)

Laravel Migration - Says unknown database, but it is created

when I use php artisan migrate, i get the error SQLSTATE[42000] [1049] Unknown database 'databaseName'.
But the database DOES exists! I even tried going back into terminal, logged into mysql and created the database again, and it said that database already exists!
Why is this giving me this error?
I have the same problem. When I run: php artisan migrate.
In my case I use Vagrant with scotch box.
To solve this, enter:
vagrant ssh
cd /var/www/yourproject
php artisan migrate
And all work well.
In your app/config/database.php file change the default value from databaseName to a real database name that you are trying to use in your application, something like this (for mysql driver):
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'your database name', //<-- put the database name
'username' => 'your user name',
'password' => 'your password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
One thing could be your casing. If you read the docs on case sensitivity it says:
the case sensitivity of the underlying operating system plays a part
in the case sensitivity of database and table names. This means
database and table names are not case sensitive in Windows, and case
sensitive in most varieties of Unix. One notable exception is Mac OS
X, which is Unix-based but uses a default file system type (HFS+) that
is not case sensitive.
Then go and check your application database setting found # app/config/database.php.
Something that looks like this:
'mysql' => array(
'read' => array(
'host' => '192.168.1.1',
),
'write' => array(
'host' => '196.168.1.2'
),
'driver' => 'mysql',
'database' => 'databaseName',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
And double check everything.
Also try using snake_case rather than camelCase for you database name.
In my case I had MySQL installed on this port: 3308, and in Laravel env file there was 3306.