Setting up MySQL managed by Adminer in XAMPP - php

I'm just having some trouble setting up Adminer in XAMPP. I'm doing something with databases for the first time, so please bear with me if this is an amateur mistake.
So I dropped the adminer.php file into the htdocs folder of XAMPP and started both Apache and MySQL servers from the XAMPP control panel.
But when I try to log in after going to localhost/adminer.php, I get the error:
Access denied for user 'abc'#'localhost' (using password: YES)
What should I do to fix this?

Reinstall Xampp
Run server, go to localhost into phpMyAdmin.php on webpage
Go to User Accounts and click in last Action "Edit privileges"
Change password (for example "123456")
Go to Xampp folder into PhpMyAdmin and open config.inc.php
Replace
- $cfg['Servers'][$i]['auth_type'] = 'config';
- $cfg['Servers'][$i]['password'] = '';
To
- $cfg['Servers'][$i]['auth_type'] = 'cookie';
- $cfg['Servers'][$i]['password'] = '123456';
Now
Donwload Adminer for MySQL and put it in htdocs.
rename Adminer****.php to Adminer.php
Open localhost/Adminer.php
Open database
localhost
root
123456
Name of database

Related

Xampp 1.8.3 localhost phpmyadmin error code 2000#

I need your help to resolve the below issue.
I have installed XAMPP server on a virtual machine having Windows 10. I changed the ports from 80 to 8080 and MySQL from 3306 to 3307. Still, I am getting an error when I try to access phpMyAdmin using localhost
Did you also change the phpmyadmin configuration to use the new port?
If not do it with the following steps:
Open the xampp controlpanel
click config behind apache -> then click phpMyAdmin
search for the line $cfg['Servers'][$i]['host'] = '127.0.0.1'; and add $cfg['Servers'][$i]['port'] = 'your new port number'; under it
save the file

Database doesn't connected on production environment

Setup on production server digitalocean's Ubuntu 18.04
production build - dist
php fpm php7.2 , mysql-server 5.7 , nginx , root#prod
very first I installed mysql-server on Ubuntu droplet according to this website.
https://support.rackspace.com/how-to/installing-mysql-server-on-ubuntu/
root is my username of the droplet and whenever I type mysql on the terminal it just promnt without asking any password to mysql shell
in my env.php file I have mentioned my database connection like this
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "123qwer";
$mysql_database = "xp";
$mysql_port="3306";
$conn = mysqli_connect($mysql_hostname, $mysql_user,
$mysql_password, $mysql_database,$mysql_port);
if (mysqli_connect_errno()) {
echo "Failed to connect to database: " . mysqli_connect_error();
}
after that I deployed my production build to the appropriate nginx serve root and it's serving my website but when I checked my database connection under inspect browser I can see this error
Failed to connect to database: Access denied for user 'root'#'localhost'
but when I try this on my Ubuntu server
ssh root#localhost
, password - 123qwer
this can login to localhost
what is the issue with my website please can anyone help me ?
You have to create user for root#localhost in your db and add read/write access to it.
use mysql shell on your server. sudo should be used.
login:
mysql -u root -p
If will ask for the password.
commands:
you can create or replace if the user does not exists. You can alter it if exists as well if you don't know its password. I guess it exists, so you can skip this step.
CREATE OR REPLACE USER 'root'#'localhost'
IDENTIFIED BY 'password';
Add privileges to all database. You can add one specific as well.
GRANT ALL ON *.* TO 'root'#'localhost' WITH GRANT OPTION;
I have Mariadb, can be some diff. You can use this for mysql if the one above doesnt work.
GRANT ALL PRIVILEGES ON database_name.* TO 'root'#'localhost';
I can't recall if the mysql daemon should or should not be restarted.
I hope it helps!

phpMyAdmin Remote Access

I am trying to access phpMyAdmin from Ubuntu remotely, and not through localhost on the Ubuntu droplet (DigitalOcean). To do this, I need to change the setup of the config.ini.php in /etc/phpmyadmin.
When running the following code:
<?php
$link = mysqli_connect("ip_address", "username", "password", "mysql")
if (!$link) {
echo "Error: Unable to connect to MySql" . PHP_EOL;
exit;
}
echo "Success: Connected to MySQL" . PHP_EOL;
echo "Host Information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
I get "mysqli_connect(): (HY000/2002): Connection refused in ...."
Tips to configuration in config.ini.php so I can use the ip address to connect?
I would comment if I could. Basically this is what you are after.
MySQL root access from all hosts
So you need to first grant privileges for table mysql to root or the username you are using for this case.
GRANT ALL PRIVILEGES ON mysql.* TO 'username'#'%' IDENTIFIED BY 'password';
Then you need edit the mysql config file
nano /etc/mysql/mysql.conf.d/mysqld.cnf
Comment out #bind-address = 127.0.0.1 then save the config file.
Restart mysql service mysql restart
First debug:
Is Your digital ocean accessible by global adress?
Second thing:
You use mysqli_connect(); You pass the arguments as a "ip_address", "username", "password", "mysql" -> That means that you do not pass variables but literally string ip_adresss; This is for stack overflow purposes?
Third thing:
In modern mysql versions ROOT user should have password and for mysql_server service should be enabled hosts others than localhosts. Try to debug that. Check the ports: 3306 by default
Fourth thing:
Do not use mysqli_connect. Try PDO or Doctrine in Your project
Make MySQL Server open to remote access connections
nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find bind-address option, change to
bind-address = 0.0.0.0
Configure phpMyAdmin to work with remote connections
If you use phpMyAdmin v5+, first of all, you have to rename config.sample.inc.php to config.inc.php
mv config.sample.inc.php config.inc.php
If yoy have an old one - just edit config.inc.php
nano config.inc.php
Find $cfg['Servers'][...] array and add after
$i++;
$cfg['Servers'][$i]['host'] = 'xxx.xxx.xxx.xxx'; //Remote MySQL IP address
$cfg['Servers'][$i]['port'] = '3306'; //or your custom port
PROFIT. Go to your phpMyAdmin and look at login form select with choosing remote connections.

Connect to remote localhost DB [duplicate]

Assuming there is a remote server and I have phpMyAdmin client installed localy on my computer. How can I access this server and manage it via phpMyAdmin client? Is that possible?
Just add below lines to your /etc/phpmyadmin/config.inc.php file in the bottom:
$i++;
$cfg['Servers'][$i]['host'] = 'HostName:port'; //provide hostname and port if other than default
$cfg['Servers'][$i]['user'] = 'userName'; //user name for your remote server
$cfg['Servers'][$i]['password'] = 'Password'; //password
$cfg['Servers'][$i]['auth_type'] = 'config'; // keep it as config
You will get Current Server: drop down with both 127.0.0.1 and one what you have provided with $cfg['Servers'][$i]['host'] can switch between the servers.
More Details: http://sforsuresh.in/access-remote-mysql-server-using-local-phpmyadmin/
It is certainly possible to access a remote MySQL server from a local instance of phpMyAdmin, as the other answers have pointed out. And for that to work, you have to configure the remote server's MySQL server to accept remote connections, and allow traffic through the firewall for the port number that MySQL is listening to. I prefer a slightly different solution involving SSH Tunnelling.
The following command will set up an SSH tunnel which will forward all requests made to port 3307 from your local machine to port 3306 on the remote machine:
ssh -NL 3307:localhost:3306 root#REMOTE_HOST
When prompted, you should enter the password for the root user on the remote machine. This will open the tunnel. If you want to run this in the background, you'll need to add the -f argument, and set up Passwordless SSH between your local machine and the remote machine.
After you've got the SSH tunnel working, you can add the remote server to the servers list in your local phpMyAdmin by modifying the /etc/phpmyadmin/config.inc.php file. Add the following to the end of the file:
$cfg['Servers'][$i]['verbose'] = 'Remote Server 1'; // Change this to whatever you like.
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$i++;
I wrote a more in-depth blog post about exactly this, in case you need additional help.
It can be done, but you need to change the phpMyAdmin configuration, read this post:
http://www.danielmois.com/article/Manage_remote_databases_from_localhost_with_phpMyAdmin
If for any reason the link dies, you can use the following steps:
Find phpMyAdmin's configuration file, called config.inc.php
Find the $cfg['Servers'][$i]['host'] variable, and set it to the IP or hostname of your remote server
Find the $cfg['Servers'][$i]['port'] variable, and set it to the remote mysql port. Usually this is 3306
Find the $cfg['Servers'][$i]['user'] and $cfg['Servers'][$i]['password'] variables and set these to your username and password for the remote server
Without proper server configuration, the connection may be slower than a local connection for example, it's would probably be slightly faster to use IP addresses instead of host names to avoid the server having to look up the IP address from the hostname.
In addition, remember that your remote database's username and password is stored in plain text when you connect like this, so you should take steps to ensure that no one can access this config file. Alternatively, you can leave the username and password variables empty to be prompted to enter them each time you log in, which is a lot more secure.
Follow this blog post. You can do it very easily.
https://wadsashika.wordpress.com/2015/01/06/manage-remote-mysql-database-locally-using-phpmyadmin/
The file config.inc.php contains the configuration settings for your phpMyAdmin installation. It uses an array to store sets of config options for every server it can connect to and by default there is only one, your own machine, or localhost. In order to connect to another server, you would have to add another set of config options to the config array. You have to edit this configuration file.
First open config.inc.php file held in phpMyAdmin folder. In wamp server, you can find it in wamp\apps\phpmyadmin folder. Then add following part to that file.
$i++;
$cfg['Servers'][$i]['host'] = 'hostname/Ip Adress';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'password';
Let’s see what is the meaning of this variables.
$i++ :- Incrementing variable for each server
$cfg[‘Servers’][$i][‘host’] :- Server host name or IP adress
$cfg[‘Servers’][$i][‘port’] :- MySQL port (Leave a blank for default port. Default MySQL port is 3306)
$cfg[‘Servers’][$i][‘socket’] :- Path to the socket (Leave a blank for default socket)
$cfg[‘Servers’][$i][‘connect_type’] :- How to connect to MySQL server (‘tcp’ or ‘socket’)
$cfg[‘Servers’][$i][‘extension’] :- php MySQL extension to use (‘mysql’ or ‘msqli’)
$cfg[‘Servers’][$i][‘compress’] :- Use compressed protocol for the MySQL connection (requires PHP >= 4.3.0)
$cfg[‘Servers’][$i][‘auth_type’] :- Method of Authentication
$cfg[‘Servers’][$i][‘username’] :- Username to the MySQL database in remote server
$cfg[‘Servers’][$i][‘password’] :- Password to the MySQL database int he remote server
After adding this configuration part, restart you server and now your phpMyAdmin home page will change and it will show a field to select the server.
Now you can select you server and access your remote database by entering username and password for that database.
As stated in answer c.hill answer, if you want a secure solution I would advise to open an SSH tunnel to your server.
Here is the way to do it for Windows users:
Download Plink and Putty from the Putty website and place the files in the folder of your choice (In my example C:\Putty)
Open the Windows console and cd to Plink folder:
cd C:\Putty
Open the SSH tunnel and redirect to the port 3307:
plink -L 3307:localhost:3306 username#server_ip -i path_to_your_private_key.ppk
Where:
3307 is the local port you want to redirect to
localhost is the address of the MySQL DB on the remote server (localhost by default)
3306 is the port use for PhpMyAdmin on the remote server (3306 by default)
Finally you can setup PhpMyAdmin:
Add the remote server to your local PhpMyAdmin configuration by adding the following line at the end of config.inc.php
Lines to add:
$i++;
$cfg['Servers'][$i]['verbose'] = 'Remote Dev server';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
You should be able to connect now at http://127.0.0.1/phpmyadmin
If you do not want to open the console each time you need to connect to your remote server, just create a batch file (by saving the 2 command lines in a .bat file).
You can set in the config.inc.php file of your phpMyAdmin installation.
$cfg['Servers'][$i]['host'] = '';
I would have added this as a comment, but my reputation is not yet high enough.
Under version 4.5.4.1deb2ubuntu2, and I am guessing any other versions 4.5.x or newer. There is no need to modify the config.inc.php file at all. Instead go one more directory down conf.d.
Create a new file with the '.php' extension and add the lines. This is a better modularized approach and isolates each remote database server access information.
In Ubuntu
Just you need to modify a single file in PHPMyAdmin folder i.e. “config.inc.php”.Just add below lines to your “config.inc.php”.
File location : /var/lib/phpmyadmin/config.inc.php OR
/etc/phpmyadmin/config.inc.php
Maybe you don't have the permission for editing that file, just give the permission using this command
sudo chmod 777 /var/lib/phpmyadmin/config.inc.php
OR (in different systems you may have to check with these two locations)
sudo chmod 777 /etc/phpmyadmin/config.inc.php
Then copy and paste the code in your config.inc.php file
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['verbose'] = 'Database Server 2';
$cfg['Servers'][$i]['host'] = '34.12.123.31';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
And make the appropriate changes with your server details
Locate the file libraries/config.default.php
then find $cfg['AllowArbitraryServer'] = false;
then set It to true
note:
on ubuntu the file in the path /usr/share/phpmyadmin/libraries/config.default.php
then you will find a new filed name SERVER in the main PHPMyAdmin page, you can add any IP or localhost for the local database.
Go to file \phpMyAdmin\config.inc.php at the very bottom, change the hosting details such as host, username, password etc.
Method 1 ( for multiserver )
First , lets make a backup of original config.
sudo cp /etc/phpmyadmin/config.inc.php ~/
Now in /usr/share/doc/phpmyadmin/examples/ you will see a file config.manyhosts.inc.php. Just copy in to /etc/phpmyadmin/
using command bellow:
sudo cp /usr/share/doc/phpmyadmin/examples/config.manyhosts.inc.php \
/etc/phpmyadmin/config.inc.php
Edit the config.inc.php
sudo nano /etc/phpmyadmin/config.inc.php
Search for :
$hosts = array (
"foo.example.com",
"bar.example.com",
"baz.example.com",
"quux.example.com",
);
And add your ip or hostname array save ( in nano CTRL+X press Y ) and exit . Done
Method 2 ( single server )
Edit the config.inc.php
sudo nano /etc/phpmyadmin/config.inc.php
Search for :
/* Server parameters */
if (empty($dbserver)) $dbserver = 'localhost';
$cfg['Servers'][$i]['host'] = $dbserver;
if (!empty($dbport) || $dbserver != 'localhost') {
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['port'] = $dbport;
}
And replace with:
$cfg['Servers'][$i]['host'] = '192.168.1.100';
$cfg['Servers'][$i]['port'] = '3306';
Remeber to replace 192.168.1.100 with your own mysql ip server.
Sorry for my bad English ( google translate have the blame :D )
In Windows with Wamp Server Installed you may find the configuration file
C:\wamp64\apps\phpmyadmin4.8.4\config.inc.php
Change the bolow line as appropriate
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = 3306;//$wampConf['mysqlPortUsed'];
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
Delete complete entries of /etc/http/conf.d/phpMyAdmin.conf
And below entires in above file,
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#ADD following line:
Require all granted
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
#CHANGE following 2 lines:
Order Allow,Deny
Allow from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
Then,
run below command in MySQL prompt,
GRANT ALL ON *.* to root#localhost IDENTIFIED BY 'root#<password>'
GRANT ALL ON *.* to root#'%' IDENTIFIED BY 'root#<password>'
For reference: Allow IP to Access Secured PhpMyAdmin

I changed MySQL port in XAMPP, now how do I listen to the new port?

I have installed the latest XAMPP with MySQL version 14.14 Distrib 5.6.21, the problem is in my computer, I already have a MySQL database installed by other program that I am using.
So I configure the XAMPP MySQL port to 3307 (default is 3306) inside the my.ini file. However, now my localhost/phpmyadmin seems to read the database installed by the other program, not the one in XAMPP, and also when I test using some PHP files, it shows that I am connected to the database even though XAMPP is turned off (XAMPP MySQL also disconnected).
How do I change the setting of my PHPMyAdmin and localhost to connect to the MySQL port 3307?
I don't understand how all these ports and the database work.
Goto xampp>phpMyAdmin Directory.
Find the config.inc.php file.
Now change this line:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
To
$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';
To configure phpMyAdmin to connect to a different port from the default, edit your config.inc.php file and add a line like:
$cfg['Servers'][$i]['port'] = '3307';
(of course substituting any port number as needed). You can also see the official documentation.
First open the following path:
C:\xampp\phpMyAdmin
Add the following string in config.inc.php file.
$cfg['Servers'][$i]['port'] = '3307';
The following worked for me, I just added my port code to:
$cfg['Servers'][$i]['host'] = '127.0.0.1:3308';
Add below line under phpMyAdmin/config.inc.php
$cfg['Servers'][$i]['port'] = port number;
in my case the port number is 8111.

Categories