Cakephp 4 MySQL on hosted environment - database

I have created a Cake solution locally and have uploaded this on my hosting provider's environment. It runs MySQL. I have full access to the respective database but of course not the MySQL main database. If I understand the situation correctly, there are multiple databases in the same environment used by other clients on different domains that I would never see.
The provider has disabled the ability to manage user rights in PHPMyAdmin. Through an admin panel I was able to create a user that is granted INSERT, UPDATE, SELECT and DELETE rights. However, with the specified datasource parameters in appl_local.php, I get the message below when I try to add a new user to the database through the users/add page. For security reasons I have marked the name of the user with asterisks in the code below.
Could it be that I have to more specifically explain on which database we are trying to execute this?
Is there a way to tell the system to always specify the database when asking for a table? For example "SELECT * FROM database_name.users" instead of just "SELECT * FROM users"? I ask this because in the message below it does not specify which database was accessed when this error was raised, only the command, the user, the table and the source code file and line number.
Or is there some schema that needs to be specified when working in a shared environment?
2021-01-07 10:39:00 Error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user '******'#'localhost' for table 'users' in /home/multigra/domains/multi-grade.nl/public_html/content/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php on line 39
'default' => [
'host' => 'localhost',
/*
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
'port' => '3306',
'username' => '******',
'password' => '******',
'database' => '******',
/**
* If not using the default 'public' schema with the PostgreSQL driver
* set it here.
*/
//'schema' => 'myapp',
/**
* You can use a DSN string to set the entire configuration
*/
'url' => env('DATABASE_URL', null),
],

This was an overight from my end. I had specified the location of information a little too much in order to learn about specifying databases when data is spread over different databases. Because the production environment connects to a different database, the requested table was not found at all. The error "SELECT command denied to user '******'#'localhost' for table 'users'" did not point me in that direction. I thought it was a permission issue. Instead, the table was not found in the database and that's why the SELECT statement failed.

Related

why the database connection symphony dont work?

i want just to host a website previously work , into another web server
i have change parameters.yml file with new host parameteres of connection
i have upload all my files , and i have import my databases
when i try to enter (myhost/web ) i have this errors : Access denied for user 'root'#'localhost' (using password: NO)
error.log
[07-Dec-2022 15:30:13 Africa/Algiers] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)' in /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('mysql:host=127....', 'root', NULL, Array)
#1 /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(45): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=127....', 'root', NULL, Array)
#2 /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'root', NULL, Array)
#3 /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /home2/icares/logicom.dz/ncomparer/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): in /home2/icares/logicom.dz/ncomparer/app/cache/prod/classes.php on line 3390
I have change the parameters of connection with new server , but the error is that username root password no and server is localhost , what i must do ?
The error.log says that your Symfony trying to access database (probably MySQL) via the user 'root' from a local host. But your database, MySQL is not set to allow access as 'root'.
MySQL and most databases do not allow to access as 'root' as default as security reason, especially without password (what your erro said).
So, may be you need to check:
What is your database_user and database_password set in Symfony project (parameters.yml?)
Check MySQL from cli that what kind of previleges are set for your database.
The way to access mysql without password may find here:
Allow linux root user mysql root access without password
Or some hints may be here:
How to create a root user with no password in mysql

Drupal 7 utf8mb4 support: "Please convert tables" warning... after converting tables

The full error I am seeing in Drush is:
Please convert all database tables to utf8mb4 prior to enabling it in settings.php. See the documentation on adding [warning]
4 byte UTF-8 support for more information. (Currently using Database 4 byte UTF-8 support Enabled, but database
tables need conversion)
I'm using the most current version of Drupal 7. I've converted all tables to utf8mb4_unicode_ci. I did so at first manually through the prompt, but then ran the updates again using phpMyAdmin on tables and fields (just to make sure, since Drush was still telling me "Please convert all database tables to utf8mb4 prior to enabling it in settings.php.") All tables are set to InnoDB.
In the my.cnf file, I've ensured that I've got
[mysqld]
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=true
Another site on the same server has utf8mb4 support enabled, and isn't throwing the error. Both sites are using latest version of PHP 5.6.x. Drush version is 8.1.2. MySql is at the latest version of 5.5.x.
I've cleared all Drupal caches via drush cc all & restarted the MySQL server. The setup is under Ubuntu with Plesk.
Looking for thoughts on what I might have missed and why Drupal is asking me to convert tables that look like they've been converted (phpMyAdmin indeed shows the collation as utf8mb4_unicode_ci.)
Pleasse see https://www.drupal.org/forum/support/upgrading-drupal/2018-04-03/upgrade-to-758-database-utf-8-issues#comment-12968331. This message is not from a deep sql analysis but hinged on the value of the boolean variable drupal_all_databases_are_utf8mb4. This variable needs to be set to TRUE after the tables have been converted whether you do it manually or by the recommended drush script (https://www.drupal.org/project/utf8mb4_convert) which (I think) will set it for you.
-Bronius
Do you have collation and charset set in settings.php?
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => 'databasename',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
);

laravel 4 local developing but I want to use a remote database

I have set up xampp server where I am developing a laravel app:
Every day (when I make an update to my app) I have to export and import the SQL from the database. That takes a lot of time if I have worked on 10 apps that day :(
Is there a way I can use the online database with a local test version of laravel?
I am using shared hosting and not migrations. I insert tables myself.
Online I see a tab:
access hosts: 'localhost'
I can add a host, but what name should I add and how can I get laravel to access this host?
Could it be 'subdomain.mywebsitename.nl/hostname'?
I'm too scared my app will crash if I change it :s
This i tried this after the solution i got:
I filled in a host. This is the same url i fill in my adress bar.
'host' => 'http://safetyanalyse.nl:2222/',
'host' => 'http://safetyanalyse.nl',
Both options do not work :( Do i have to put the port number somewhere else?
I also have this error:
SQLSTATE[HY000] [1130] Host 'D97A1650.cm-3-3a.dynamic.ziggo.nl' is not allowed to connect to this MySQL server
Step 2 (next i tried this).
In the error it says something about the host, i tried filling in this host.
'host' => 'D97A1650.cm-3-3a.dynamic.ziggo.nl',
Now i get the error:
SQLSTATE[HY000] [1045] Access denied for user 'safety_cert-user'#'d97a1650.cm-3-3a.dynamic.ziggo.nl' (using password: YES)
Try to use domain name as host, that should work.
Also, look for port, if specified.
All this information should be provided to you is hosting control panel. If not, I would change hosting provider.
Edit
Define your host without protocol.
In your app/config/database.phpset
'host' => 'safetyanalyse.nl',

How to connect to MS SQL in Rails

I am attempting to migrate legacy data from a MS SQL database into my Rails Application. I have added configuration in freetds which is connecting properly. In my Gemfile, I have added the tiny_tds and activerecord-sqlserver-adapter, respectively.
I have created a file to house the classes from the legacy database to translate to ActiveRecord:
class LegacyUser < ActiveRecord::Base
establish_connection :legacy
set_table_name 'users'
end
.
.
.
database.yml
legacy:
adapter: sqlserver
mode: odbc
dsn: legacy_db_name
host: db_host_name
database: legacy_db_name
port: 1433
username: username
password: password
Then I have rake tasks to convert the data:
legacy.rake
desc 'migrate users'
task :users => :environment do
require 'lib/tasks/legacy_classes'
LegacyUser.each do |user|
begin
new_user = User.new
new_user.attributes = {
:firstname => user.firstname,
:lastname => user.lastname,
:email => user.email,
:created_at => Time.now,
:updated_at => Time.now
}
new_user.save!
puts "User #{user.id} successfully migrated"
rescue
puts "Error migrating #{user.id}"
end
end
At this point I am just trying to get the rake task to 'connect' to the legacy database.
When I try 'rake users', I get:
rake aborted!
database configuration does not specify adapter
It looks to me like I have clearly specified the adapter. What is the proper way to configure this?
Also as a side question, in my 'classes' file for legacy database tables, should all of those tables mirror the 'new' Rails database schema? Ideally I want to be able to simply connect to various tables in the legacy database and fit them into the new database schema where needed. The associations in the old do not match the new, nor do the naming conventions.
Any help is appreciated. Thanks.
Update
Still experiencing this error. Sadly, the only threads I could find that have had the same error were odd spacing issues in the database.yml file. So I actually took the time to go through and make sure all of the spacing matched my other configurations. Given that it is a vague error I am not really even sure what to check past the instructions for setting up activerecord-sqlserver-adapter.
Got an answer to this here: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/250
'You can try connecting to your DB like so, this works for us on that branch on Rails 4:'
class LegacyTable < ActiveRecord::Base
establish_connection({
:adapter => "sqlserver",
:host => "host",
:username => "user",
:password => "pass",
:database => "dbname"
})
This solved my issue. Hope it helps someone in the future.

DB2 creating event monitor

I'd like to create event monitor on DB2 z/OS 9.2
i have spent a lot of time trying resolve this problem.
So i suggest this link: http://www.ibm.com/developerworks/data/library/techarticle/0303kolluru/0303kolluru.html
and trying to make this steps:
db2 => connect to dbname user username using password
db2 => update monitor switches using statement on
db2 => create event monitor rkmon for statements write to file '/tmp'
db2 => set event monitor rkmon state=1
but when I put command: create event monitor rkmon for statements write to file '/tmp'
Db2 throw me an error:
"DB2ADMIN" does not have the privilege to perform operation "CREATE EVENT MONITOR".. SQLCODE=-552, SQLSTATE=42502, DRIVER=3.58.81
so, then i try add some privilege to my db2admin user:
grant DBADM to db2admin
but get another error:
The name "DBADM" cannot be used because the specified identifier is reserved for system use.. SQLCODE=-707, SQLSTATE=42939, DRIVER=3.58.81
Now, I don't have any idea what shoould i do to resolve this problem.
Maybe, there is some othere way to logs sql queries sends to my db2 ?
(I develop some java apps using hibernate and db2, and sometimes quickest way to resolve some problem is see what sql queries is send to db).
Any ideas ?
Thanks
I think the "ON DATABASE" clause is mandatory in the GRANT statement. Try:
grant DBADM on database to user db2admin
GRANT (database authorities)
statement

Resources