PHP 5.2 based app unable to connect to Google Cloud SQL - mysql

We have a PHP 5.2 based app which we migrated to GCE, and encountered the problem where the Mysqli client does not work.
We used Atomic Archive repo to install PHP 5.2 on GCE 6 CentOS 6:
http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/
and also installed the provided Mysql client:
mysql-5.5.40-26.el6.art.x86_64.rpm
Following testing, the application fails with following error:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on XXX.XXX.XXX.XXX
While the command line mysql client works just fine.
While looking at the mysqli.so PHP extension, we noticed it uses the oldest available MySQL library: /usr/lib64/mysql/libmysqlclient.so.16
Any chance that this library doesn't work with Google Cloud SQL?

This is how I connect from my php:
$conn = mysqli_connect("<IP>", "<username>", "<password>","database") or die ("Error" . mysqli_error($conn));

Related

Unable to query Presto database using Dbvisuallizer- Error Executing Query

We are trying to connect to presto using Dbvisualizer . and execute some queries . Catlog we are using is mysql .
Presto is installed in the linux server . presto cli is working fine in the linux . Started presto in linux .
Mysql is also installed in the linux machine . We are able to access mysql in windows using Dbvisualizer.
Created a mysql connector catalog for Presto. Successful in querying data of mysql using Presto-cli
as presto --server localhost:8080 --catalog mysql --schema tutorials
DBvisualizer is installed in the Windows machine . I'm able to access mysql and execute queries .
Presto also connected in Dbvisualizer . But we are unable to query data .
When we try to run a query . It is giving us Error Executing Query .
There is not much information available online , We dont know what we are missing here , Can Someone explain me the way to do this .
We need to execute queries from windows machine . we also tried from java code using jdbc jar . same exception
Added the Screenshot of Config.properties of the Presto Installation . Any property more to be added here?
. Any suggestion is appreciated . Thanks
It seems like you haven't installed any way to authenticate to use Presto. The authentication that exists on your MySQL instance is not used to authenticate users that access your Presto cluster.
There is a critical security vulnerability in Presto where "authenticated users can bypass authorization checks by directly accessing internal APIs". This has only been resolved in the Trino (formerly PrestoSQL) distribution so I recommend you use Trino if you plan on running a secured cluster in production.
Your options on Trino are, LDAP authenticator, Password authenticator, and Kerberos authenticator (don't recommend unless you already use Kerberos). Configure these first before trying to use SSL/TLS on your server.
You can also find help you with any further questions for setting up a secure cluster on the Trino slack channel.

new sonarqube(docker) can't connect to existing database that was serving old sonarqube (server)

We installed sonarqube version 6.7(33306) on centos7.2 server with mysql 5.6 database. Its working for 3 months now and has data we need to preserve.
We want it on Kubernetes/Docker > I configured the official sonarqube docker image 6.7(33306) to connect to a new mysql5.6 database. works but the db is empty.
Now I need my real data/db working with the new dockered sonarqube. I dumped the existing DB and imported it on the new DB that dockered sonarqube connects to. Now when I try to connect from the docker image to the new db I get this error.
SonarQube Server / 6.7.0.33306 /
5d031d9d2ac3f69b4b9bc600d50563b1886c7d8b
INFO web[][o.sonar.db.Database] Create JDBC data source for
jdbc:mysql://192.168.27.104:3407/sonarqube?
useUnicode=true&characterEncoding=utf8&autoReconnect=true
INFO web[][o.s.s.p.ServerFileSystemImpl] SonarQube home:
/opt/sonarqube
INFO web[][o.s.s.u.SystemPasscodeImpl] System authentication by
passcode is disabled
ERROR web[][o.s.s.p.Platform] Web server startup failed: Current
version is too old. Please upgrade to Long Term Support version
firstly.
Both sonarqubes are the same version and the original was not upgraded from an older version.
Ive tried the latest sonarqube docker with the tag lts, its the same error.

Perl DBD mysql with SHA-256 Authentication fails

I am trying to set up Perl to connect to a mysql database.
i am using Perl 5.16, as this is a requiment,
DBI 1.622 with DBD:mysql from cpan was build.
The mysql database is Version 5.6.26
The mysql database uses SHA256 authentication, this won't be changed and there must not be set up an account with old_authentication or native.
I can not connect to the database as it replies with
Client authentication scheme is not supported.
My short test script is
use DBI;
use DBD::mysql;
$dbh = DBI->connect('DBI:mysql:host=dbhost', 'dbtest', 'test'
) || die "Could not connect to database: $DBI::errstr";
The returned error message is
DBI connect('host=dbhost,'dbtest',...) failed: Client does not support authentication
protocol requested by server; consider upgrading MySQL client at dbtest.pl line 4.
Could not connect to database: Client does not support authentication protocol requested
by server; consider upgrading MySQL client at dbtest.pl line 4.
How can i set up a Connection to the Server?
edit : This is not a duplicate. The User is allowed to access from any host, and we do not want to roll back to old Password, as written above
#martinclayton is correct. You have a very old version of your PERL MySQL DBD module. The upgrade to 4.1 happened over a decade ago.
Read this: https://dev.mysql.com/doc/refman/5.5/en/old-client.html
You need to upgrade your DBD module. Martin's link will give you some hints how to do it. http://search.cpan.org/~capttofu/DBD-mysql-4.032/lib/DBD/mysql/INSTALL.pod#PREREQUISITES

Google Cloud SQL SSL fails peer certificate validation

I have an issue using MySQL on PHP 5.6, and after three days of debugging PHP, OpenSSL, MySQLnd Drivers on PHP and trying out the mysql_client on an Ubuntu 14.04 machine, I have come to a conclusion: Google Cloud SQL SSL certificates will not work on PHP 5.6 and above.
For a start, the Google Cloud is a great service, and modern cryptography is enforced throughout the Google ecosystem. However, I couldn't use it because of one little problem: Google Cloud SQL SSL Server certificates have impossible common names.
Google Cloud SQL Server (or peer) certificates have a Common Name (CN) that looks something like:
CN=project-name:instance-id
To make matters worse, starting from PHP 5.6, all encrypted client streams will go through mandatory peer certificate validation. (Link: OpenSSL changes in PHP 5.6.x). I use the PHP Data Objects (PDO) extension, which uses the native driver MySQLnd to handle all the MySQL business. This uses the native PHP streams to handle those connections.
I have been looking through the MySQLnd source code on PHP (Link: MYSQLnd Driver Code on GitHub), MySQLnd configuration options to try and disable the SSL peer verification code on this particular MySQLND. To no avail.
Therefore, what should I do if I need to use SSL for MySQL connections on PHP 5.6?
Your response is greatly appreciated!
Try connecting through the proxy if you have second generation sql, you might be able to connect pdo via the proxy with 127.0.0.1: https://cloud.google.com/sql/docs/compute-engine-access#gce-connect-proxy
Assuming you can convince MySQL that the hostname is should verify is in fact project-name:instance-id then I would have thought the hostname validation ought to succeed (though I agree that cert doesn't look great).
I tried the following from my Mac OS X workstation and it appeared to succeed, at least when using the mysql binary (I didn't try via PHP).
First I added a hosts entry on my machine included the colon as part of the name:
1.2.3.4 project-name:instance-id
After doing so I was able to connect successfully with the mysql (5.6.32) installed on my machine:
mysql -uroot -h "project-name:instance-id" --password \
--ssl \
--ssl-ca ~/Downloads/server-ca.pem \
--ssl-cert ~/Downloads/client-cert.pem \
--ssl-key ~/Downloads/client-key.pem \
--ssl-verify-server-cert
(When I ran that same command with the IP address instead, I received ERROR 2026 (HY000): SSL connection error: SSL certificate validation failure)

Magento-Check.php thinks I'm using a lower MySQL version than I am

I've been having some site problems while developing and decided to run the magento-check.php file to see if everything is up to scratch. The results are.
Your server does not meet the following requirements in order to install Magento.
The following requirements failed, please contact your hosting provider in order to receive assistance with meeting the system requirements for Magento:
You need MySQL 4.1.20 (or greater)
The following requirements were successfully met:
You have PHP 5.2.0 (or greater)
Safe Mode is off
You have the curl extension
You have the dom extension
You have the gd extension
You have the hash extension
You have the iconv extension
You have the mcrypt extension
You have the pcre extension
You have the pdo extension
You have the pdo_mysql extension
You have the simplexml extension
The problem is that I am running MySql Server version: 5.5.24-0ubuntu0.12.04.1
Also note that Magento is already installed on the server and operating.The problems I've been having are consistant 500 Internal Server Errors just on product pages. I don't think these problems are related but it's still odd.
I'm not sure there's a question in there, but if you're talking about the magento-check.php script distributed here
http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento/
This gets the version of mysql with the following comment
preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
and then compares using
if(version_compare($version[0], '4.1.20', '<')) {
In other words, the script runs the following shell command
$ mysql -V
and then looks for a X.X.X version number in the output. For example, this
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.1.41, for apple-darwin9.5.0 (i386) using readline 5.1
means the script thinks the version is 5.1.41.
My guess is you're using a remove server. This means the script above checks the version of the mysql cli client running locally. It's also possible you don't have any mysql running locally, which means the script would try to parse the text
mysql: command not found
for a version number, and not find one.
As to your 500 Internal Server Errors, this means apache has an error, or PHP has an error. Check their error logs respectively to see what the error is.
You need to check Exact magento version support with php & mysql,i hope the below code may be help to check Exact Version PHP & MySQL
##Test What Exact Version PHP & MySQL
echo "<h2>Exact Version PHP & MySQL: </h2>";
printf("PHP version: %s\n", PHP_VERSION);
$mysql = mysqli_connect('localhost', 'devonbd_com', 'XSZefjGW');
#$mysql = mysqli_connect('localhost', 'root', '');
## Test the MySQL connection
if (mysqli_connect_errno()) {
printf("</br> Connection failed: %s\n", mysqli_connect_error());
exit();
}
## Print the MySQL server version
printf("</br> MySQL server version: %s\n", mysqli_get_server_info($mysql));
##Close the MySQL connection
mysqli_close($mysql);
I just solved this issue. It turns out that the MySQL warning might be a false alarm; for me, changing the PHP Version (I am using MAMP) from 7 to 5.6 did the trick. Looking at some forums, lowering the PHP version from 5.3 to 5.2 also worked for some.