I've upgraded from a 6 year old Xampp to the next latest one:
xampp-win32-7.0.23-0-VC14-installer.exe
Before install I did a Mysql Dump All:
mysqldump -u root -p --all-databases > all-db-dump.sql
After install I Imported that all-db-dump.sql from phpMyAdmin.
When starting my PHP-application filmtv.php I get the above errors, see attached filmtv.php.png.
Look at the source samples and I hope someone out there have an idea of whats wrong, cause I expected it to work smoothly without having to change my application.
Also, if I do a minor change using phpMyAdmin like adding a new user then I cannot use phpMyAdmin anymore it'll respond that user/pwd is incorrect, very strange. Up to now I've done 5 re-installs because of that.
From phpMyAdmin user:
root localhost Yes ALL PRIVILEGES
filmtv.php
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in C:\xampp\htdocs\css\bertil.php on line 2
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in C:\xampp\htdocs\css\bertil.php on line 3
Fatal error: Uncaught Error: Call to undefined function mysql_error() in C:\xampp\htdocs\filmtv.php:156 Stack trace: #0 {main} thrown in C:\xampp\htdocs\filmtv.php on line 156
filmtv.php includes
include 'css/adam.php';
include 'css/bertil.php';
if (!$cxn) { echo "Unable to connect to DB: " . mysql_error();
exit;}
Source-code:
*adam.php:*
<?php
$user="root";
$host="localhost";
$password="tenthirty";
$database = "ljung";
?
*bertil.php:*
<?php
$cxn = mysqli_connect($host,$user,$password,$database);
$cxu = mysqli_connect($host,$user,$password,$database);
?>
_By the way, my Xampp install is:
Includes: Apache 2.4.27, MariaDB 10.1.26, PHP 7.0.23, phpMyAdmin 4.7.4, OpenSSL 1.0.2, XAMPP Control Panel 3.2.2, Webalizer 2.23-04, Mercury Mail Transport System 4.63, FileZilla FTP Server 0.9.41, Tomcat 7.0.56 (with mod_proxy_ajp as connector), Strawberry Perl 7.0.56 Portable_
_
Cheers,
Torbjorn
Stockholm
In the newest version of Xampp they start to use mariadb instead of mysql
so you can't log in as root user so you have to create new user and grant your privileges in that user
Related
I have a PHP script that connects to a database, selects rows from a table:
db.php:
function connect() {
try {
$this->connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($this->connection->connect_error) {
die("\nConnection failed: " . $this->connection->connect_error);
} else {
print "\nConnected successfully\n";
}
} catch (Exception $e) {
echo 'Exception: ' . $e -> getMessage();
die("\nConnection failed: " . $this->connection->connect_error);
}
}
It works without fail when I run it in terminal - connects and retrieves all the data from the table.
However when I copy the file to a /opt/lampp/htdocs/myapp and open it, I get the error:
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in /opt/lampp/htdocs/myapp/db.php on line 15
Connection failed: Access denied for user 'root'#'localhost' (using password: YES)
Warning: mysqli::close(): Couldn't fetch mysqli in /opt/lampp/htdocs/myapp/db.php on line 61
I don't know how to fix it. I tried to add 192.168.1.1 to /etc/hosts file. Now it looks like this:
127.0.0.1 localhost
127.0.1.1 parsecer
192.168.1.1 parsecer
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I tried commenting out the bind-address line in /etc/mysql/mysql.conf.d/mysqld.cnf :
...
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
...
However I still get that error...
EDIT: I managed to replicate the access denied error inside Terminal (IDE) by using localhost:3306 instead of just localhost as a host name...
EDIT: I tried running like this:
$this->connection = new mysqli("localhost", "root", "correctpassword", "stuff", 3306);
In Terminal (IDE) it WORKS
In browser - access denied error
I also have this in the mysqld.cnf file:
[mysqld]
skip-grant-tables
EDIT:
select user, host from mysql.user
gives this:
EDIT:
I created a new user in MySQL, gave it all privileges, the code works
with the new user in Terminal doesn't in browser.
EDIT:
I turned off MySQL in XAMPP panel, but MySQL still works in terminal, so I think there are two different MySQLs on my PC.
Now the code works in terminal but in browser gives
Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /opt/lampp/htdocs/stuff/db.php on line 16
Connection failed: No such file or directory
Warning: mysqli::close(): Couldn't fetch mysqli in /opt/lampp/htdocs/stuff/db.php on line 67
I also added
bind-address = 0.0.0.0
to /etc/mysql/mysql.conf.d/mysqld.cnf
UPDATE WITH ANSWER:
A user #Shadow guessed correctly that I had two versions of Postgres running simultaneously. One I installed manually and the other was installed with a XAMPP package.
I removed the whole XAMPP package, manually installed Apache server (which was part of the XAMPP as well), and then, having only one Postgres and one Apache manually (using terminal) run both and the code worked!
A user #Shadow guessed correctly that I had two versions of Postgres running simultaneously. One I installed manually and the other was installed with a XAMPP package.
I removed the whole XAMPP package, manually installed Apache server (which was part of the XAMPP as well), and then, having only one Postgres and one Apache manually (using terminal) run both and the code worked!
I have Windows 10/x64, Apache24, MySQL 8.0, PHP 7.2.10
I'm trying to connect database:
$conn = mysqli_connect('localhost', 'user', 'test123', 'ninja_project');
if (!$conn) {echo "Connection error:" . mysqli_connect_error();}
But keep getting this warnings:
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in C:\Users\User\www\phptutorial\ninjapizza\index.php on line 3
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'user'#'localhost' (using password: YES) in C:\Users\User\www\phptutorial\ninjapizza\index.php on line 3 Connection error:Access denied for user 'user'#'localhost' (using password: YES)
I've already done some things to solve the issue:
Checked solution through same topics already discussed on stackoverflow, but found nothing helpful in my case.
Enabled openssl in php.ini extension=openssl.dll
Specified directory extension_dir = "c:\php\ext"
Checked openssl status through CMD '''php -i''' - openssl support => enabled
Checked openssl modul through CMD '''php -m''' - got openssl in list
Checked localhost/index.php - openssl enabled
Checked file php-cli.ini on my PC - don't have one
I tried to rename $conn = mysqli_connect('localhost' to $conn = mysqli_connect('127.0.0.1'. Doesn't work. Same problem.
Granted All privileges to User.
I have openssl.cnf in directory C:\php\extras\ssl
I have openssl.cnf in directory C:\Apache24\conf
I have installed OpenSSL on Windows and have openssl.cnf in directory C:\Program Files\OpenSSL-Win64\bin
I specified directory for OPENSSL_CONF different ways
set OPENSSL_CONF=c:\php\extras\ssl\openssl.cnf
set OPENSSL_CONF=c:\Apache24\conf\openssl.cnf
set OPENSSL_CONF=c:\Program Files\OpenSSL-Win64\bin\cnf\openssl.cnf
According to this page https://www.php.net/manual/en/openssl.installation.php I must to compile PHP --with-openssl[=DIR]. But I have no idea how to do this properly. I'm only on the level to learn PHP and MySQL.
I restarted Apache many times. Don't know what can I do else!
I have MySql 8.0 freshly server installed. Initially, I was able to log in, but when I tried to connect to it through PHP PDO I got this error:
Fatal error: Uncaught PDOException: PDO::__construct(): The server
requested "authentication method unknown to the client
[caching_sha2_password]"
I read from StackOverflow a solution here
Open your my.cnf (in my case the my.ini file) and add the following
entry (and restart MySQL)
[mysqld]
default_authentication_plugin=mysql_native_password
Create a user (your MYSQL_USER name) using the correct 8.0 syntax for
generating the password (see below) <---- Altered my existing user
"root"
IDENTIFIED WITH mysql_native_password
Flush the privileges and try again.
After I restarted the MySql service I'm now unable to log in to MySQL. with it saying this error now:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using
password: YES)
I want to be able to log in through PHP PDO, but I can't even log back in through regular command prompt or MySQL Workbench. Any help on this would be great.
Software:
PHP 7.3
MySQL Workbench 8.0
This is my PHP code:
try {
$link = mysqli_connect($DB_SERVER,$DB_USERNAME, $DB_PASSWORD,$DB_NAME,3306);
} catch (Exception $e){
throw new Exception("Can't execute command. ERROR: ".$e);
}
This is the error:
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in login.php on line 11
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'XXXXX_admin'#'localhost' (using password: YES) in C:\inetpub\wwwroot\ on line 11
PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\inetpub\wwwroot\ on line 24
PHP Fatal error: Uncaught Exception: ERROR: Failed to connect to in C:\inetpub\wwwroot:24 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\ on line 24
Now the magic, when I login in to mysql workbench with the same user and password everything works fine. I have access to tables and other things. When I login in with my PHP application everything works also.
So my problem is everytime my server reboots I have to login in with MySQL Workbench, to get it working again. What am I missing?
You need to do verify few of the steps:
All necessary extensions are enabled like mysqli, openssl etc
Port is available
MySQLi is connecting at 3306 Port
Rest could be your username and password issue
Let us know once you will be verifying all above steps.
What you need to do is enable the openssl extension for php.
Open your php.ini file and search for the line:
;extension=php_openssl.dll
You need to uncomment it by removing the semicolon in front of it, leaving you with this:
extension=php_openssl.dll
I tried to move a database from XAMPP to my Synology NAS.
Now I get this error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'qs'#'localhost' (using password: YES) in /volume1/web/db.php on line 3
In the Database i created a User:
Name: qs
password: test
host: %
privileges: all..
in php i use:
$link=mysqli_connect("localhost","qs","test","qs",3306);
localhost because the Synology is the localhost of the web-page. i also tried to change to:
$link=mysqli_connect("10.0.0.99","qs","test","qs",3306);
then it says:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'qs'#'JF_SYN' (using password: YES) in /volume1/web/db.php on line 3
"JF_SYN" is the name of my Synology
i also tried to set the host of the database user, to that specific IP, but that doesn't change anything.
Database connection is working with this user and the password, i tried with HeidSQL,MSYQL-Workbench and Oracle SQL Developer, all those tools can make a connection.
I had the same issue, with my Synology NAS
Use MyAdmin and remove the “ANY” or “Anonymous” user accounts.
This should Fix your issue.