PHP Can't connect to external Mysql after apt upgrade - php

Using Ubuntu 16.10
I have been using external Mysql server just fine, but today I did an apt update and apt upgrade, after that. PHP simply won't connect to external mysql server anymore. I can connect the server via command line using mysql though, but php just does not. I tried simple script to open to connection and
mysqli_connect_error(); just gives out an error "connection refused"
Ports are open. Any idea why this suddenly happened after an update?
EDIT: Updated the client server. The server where external mysql is running works fine, I can connect to it from other servers. But one client server where php script runs can't access it after an update.

Found it. php 7 does not support ip:port anymore, but port has to be set up separately. Changed the default port via: ini_set('mysqli.default_port', 'port'); in the file where connection was made as I was unable to change it in the script I am using.

Related

Connection doesn't established when connect to sql server via php

I have already Docker and SqlServer which is works normally. Now i want to connect to sql server with php. it gives me could not find driver error. I use php 8 on centos 7. How can i fix it?

PHP pdo_dblib extension works via HTTP but not via CLI

One of our customers uses the pdo_dblib PHP extension to connect to an external Sybase database using FreeTDS.
The connection works perfectly through HTTP requests, but when he calls the PHP script through CLI (using PHP binary), the connection fails:
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (connection_name) (severity 9)
The strange thing is that running through root user works, but not through their user.
Worth mentioning that this is hosted on a cPanel server, so maybe it has something to do with it.

phpMyAdmin unable to connect with mysql

I had installed MAMP on my windows 10 machine. I had then configured the MySQL thru the phpMyAdmin and had installed the WordPress. Later due to certain issues, I had to un-install and re-install the MAMP again. This time Apache started running and I could reach localhost/MAMP/, but when I click on phpMyAdmin, I get the message:
"mysqli_real_connect(): (HY000/2002) No connection could be made
because the target machine actively refused it
.....You should check the host, user name and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server". I ran the command> MySQL -u root -p status. It asked for a password. On giving the password, I got the following: Error 2003 (HY000) Can't connect to MySQL server on localhost (10061).
Please help with a workaround.
The error was resolved thru re-installation and taking care to disable the installation of MAMP Pro which happens by default.
I usually see the "actively refused" error when I try to connect to a port that the MySQL server is not actually running on. That said, I don't know why this would happen out of the blue. Maybe you should be using WAMP instead of MAMP?
You could probably troubleshoot this issue remotely with third party tools that have debug logging (MySQLShell through its Application Log)
Check all your Microsoft Redistribute Packages are installed correctly. If the problem exist then use the XAMPP or WAMP for the Windows because MAMP is generally used for the MAC OS.

MySQL Workbench 5.6 crashes on connection to localhost

I'm running Apache 2.2 and MySQL Workbench, and using PHP to access the database.
The problem is, when I try to open the database I've made, MySQL Workbench can't seem to connect to the localhost at port 80, and the program stops responding.
How can I fix this?
Update: After some time of the program simply not responding, it gave me this error message:
"Unhandled exception: Lost connection to MySQL server at 'waiting for initial communication packet', system error 10060 (code 2013)"
A wamp installation has a lot of issues. Instead, you can run a Virtual Machine with ubuntu and run there LAMP. it is way more reliable than running wamp that is not supposed to be "equal" in terms of your production environment - that for sure is linux based OS. Also, keep in mind that programs such skype blocks the port 80 and 443. Search what programs are using the port for mysql... that's why I don't develop AMP apps under windows, but under linux.

How to activate the mysql database in xampp on windows platform?

I've installed XAMPP on my Windows XP. I started the XAMPP control panel and it shows apache and mysql are running.
When I check the status by going to localhost/xampp it shows:
mysql : deactivated
When I run php files that access the mysql database, it shows the following errors:
Warning: mysql_connect() [function.mysql-connect]: [2002] No connection could
be made because the target machine actively refused it. (trying to connect
via tcp://localhost:3306) in C:\xampp\htdocs\Elo_algorithm.php on
line 18
I've been through the XAMPP troubleshooting page and FAQ but I don't understand what to do. The XAMPP control panel shows mysql is running, but xampp status shows: deactivated.
What is going on here?
OK I got this issue resolved in my case, hopefully will help you too. Problem was system itself. If you run Vista, Win7, win8 you probably have permission issue. Simple go to XAMPP root and find mysql_start.bat and run it. Immediately after clicking your firewall will appear with message asking for permission. All you have to do is to allow permission (for private networks such a home or work network).
MySQL database ACTIVATED - and that's what matters ;)
I hope that helps to all of you who did not get an answer so far.
Cheers!
You should view in the xampp installation the file "\xampp\mysql\data\mysql_error.log".
This file contais the error log of MySQL and in it you can detect any problem like por in use.
For example, this lines of log show that the port 3306 (the mysql default) is used by another application and can't be accessed.
111130 8:39:56 [ERROR] Can't start server: Bind on TCP/IP port: No such file or directory
111130 8:39:56 [ERROR] Do you already have another mysqld server running on port: 3306 ?
111130 8:39:56 [ERROR] Aborting
If all in the MySQL is correct probably the problem is related to the driver in the php application. Currently PHP has two MySQL connector types, the "mysql" and the "mysqli", MySQL "mysql" connector, that use "mysql_" (the method that you are using to connect is mysql_connect) prefixed functions, is used for old MySQL 4 applications and when the MySQL 5.x if is in configured with the "old password" parameter. The "mysqli" is used for the new mysql 5.x versions and in php you must use "mysqli_" prefixed functions like "mysqli_connect.
The version used by the lastest versions of xampp is MySQL 5.5 and you require to used the mysqli connector.
Check whether the value of port variable in the "my.ini" file in your xampp mysql folder is 3306 or 8888
i was facing the same problem. I had to run setup-xampp.bat to make it working.
By the way I came across a new WAMP stack called AMPPS. It looks quite easier than XAMP. You should try. http://www.ampps.com
I could not get XAMPP for Windows (1.7.4 Beta2--I know; ancient) to work on Windows 7 (32 bit) as the MySql would not "activate" or connect to Apache. Just by dumb luck I installed .NET Framework 4.6 for another application and suddenly--Whoopee! It started working!

Categories