Can't access MySQL from Glassfish pool - mysql

I have a connection pool created by following a tutorial. Also there is MySQL created from XAMPP, running on port 3036.
Connection pool attributes are:
user admin
password admin
URL jdbc:mysql://localhost:3036/test2
In my.ini of MySQL I added
[client]
user=admin
database=test2
password = admin
port = 3036
But when I try to ping, I catch an error:
Ping Connection Pool failed for Test2. The connection could not be
allocated: Access denied for user 'admin'#'localhost' (using password:
YES)
What's wrong with settings?

Run your mssql shell as root and try to execute:
GRANT ALL ON test2.* TO 'admin'#'localhost';
maybe this would help.

Related

Have phpmyadmin and apache, but need to log in to database (Linux Mint)

I am new to linux but learning it pretty well. I have apache working on localhost, I installed mysql through this package: mysql-server 8.0.19-obuntu5
But I need to create a user that works with phpmymadmin and mysql and has access to all the databases. I'm getting these error with root (would post photo but the photos are causing post problems):
Cannot log into mysql server then
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'#'localhost'
Connection for controluser as defined in your configuration failed.
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'#'localhost'
See my config here, without the dollar sign char for vars and colins:
dbuser 'root'
dbpass 'Edited Out For This Post'
basepath ''
dbname 'phpmyadmin'
dbserver 'localhost'
dbport '3306'
dbtype 'mysql'
What should I do to get me logged into all my dbs. Willing to make new user.
Many versions of phpmyadmin disallows root login. Hence, run the following to login as root (in console)
sudo mysql -p -u root
then create a new user (say pmauser) with
CREATE USER 'pmauser'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password_here';
then grant this user the permission
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'#'localhost';
Now try login phpmyadmin by pmauser

mysqli::real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO) error on Mac

This is the error message I got after I tried to make a password and username for localhost and root. Please help me. I am using Mac by the way.
MySQL said: Documentation
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
go to xampp\mysql\bin\my.ini and open it. change the port to 3307
and go to xampp\phpMyAdmin\config.inc.php and check the name of the host
$cfg['Servers'][$i]['host'] = 'localhost:3307';
Adding to soufiane's answer above, there is actually 2 more places where you have to make the same change:
xampp window: config > Service and Port Settings > mysql > Change port to 3307
add $cfg['Servers'][$i]['port'] = 3307; to phpMyAdmin\config.inc.php
For a complete start to finish solution, refer to this answer on Quora by Owais R. Mir: https://www.quora.com/How-do-I-change-the-port-of-a-MySQL-server-in-XAMPP/answer/Owais-R-Mir
PS:
I used this solution to run mysql from xampp on port 3307 because I had installed mysql separately before and it was using port 3306. When ports are reset for xampp mysql you avoid issues with initializing and signing in to your local database via phpmyadmin.

Mysql connect to remote server successfully using command line but access denied when start service

I have an internal server, which run MySQL server on port 3306. I connect to this server via VPN
connect successfully using command line. 10.10.x.x is my internal server ip
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u adnet -p -h 10.10.x.x
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4597054
Server version: 5.5.44-37.3 Percona Server (GPL), Release 37.3, Revision 729fbe2
But when I start a Java service, I get an error. 10.79.x.x is my ip
java.sql.SQLException: Access denied for user 'adnet'#'10.79.x.x' (using password: YES)
This is my db config
db {
default {
url = "jdbc:p6spy:mysql://10.10.x.x:3306/adnet_dev?characterEncoding=UTF-8"
username = "adnet"
password = "xxx"
}
}
Access denied also happen when I use Database tool in Intellij
Does anyone have any idea what is the cause of the problem. Thank you
My IP already granted full privileges
I figure it out, My Ip was granted privilege without IDENTIFIED BY. I start my service successfully with password empty
db {
default {
url = "jdbc:p6spy:mysql://10.10.x.x:3306/adnet_dev?characterEncoding=UTF-8"
username = "adnet"
password = ""
}
}

trouble connecting to mysql 5.7 on AWS instance

I launched an EC2 instance on AWS and am using Ubuntu. I am able to connect to MySQL on the instance itself.
(i.e. mysql -h localhost -u root -p)
but when I try and connect from my remote computer
(i.e. mysql -h ipaddress -u remoteUN -p)
ERROR 2003 (HY000): Can't connect to MySQL server on 'ipaddress' (61)
I have changed my security settings to allow all IP addresses to connect to port 3306, as well as port 22, and on the instance I created a user that can access MySQL from a remote server
> CREATE USER 'tempuser'#'%' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON *.* TO 'tempuser'#'%'
> WITH GRANT OPTION;
I tried to start/stop the mysql server using
> service mysqld restart
and get the following
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'mysqld.service'.
Authenticating as: Ubuntu (ubuntu)
Password:
I'm not sure what the default password is, and when I enter my MySQL password I get
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart mysqld.service: Access denied
See system logs and 'systemctl status mysqld.service' for details.
> systemctl status mysqld.service
mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Anyone know what default password is or how to restart the server so that I can connect remotely?
What is disabled by default is remote root access. If you want to enable that, run this SQL command locally:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Now as of not being able to connect remotely you will have to comment out bind ipline in my.cnf file which usually lives on /etc/mysql/my.cnf on Unix/OSX systems. In some cases the location for the file is /etc/mysql/mysql.conf.d/mysqld.cnf).
Find the Line :
bind-address = 127.0.0.1
and comment it out by adding # in front of it save and restart mysql , you should be able to connect to it remotely.
Hope this helps !

Access denied to remote MySQL connection request

I have a mysql database (v5.5.41) setup on a remote server and an application connects to the DB from another server to run some queries. It's been working fine but recently my DB server got a new IP address. My application can't connect to the DB anymore, the connection times out.
The application is using the DNS name of the server, not a hard-coded IP, so there shouldn't be a problem. In any case, if I run this from the application server:
mysql -u app_user -h mydb.myhost.com -p
then I get
ERROR 1045 (28000): Access denied for user 'app_user'#'xxx.xxx.xxx.xxx' (using password: YES)
If it was having trouble finding the new IP, then that command would probably just hang and timeout, so it seems to be an authentication issue. My password is definitely correct, but the application is using the same password as when the app was connecting successfully so it's not an issue of mistyping it.
I've tried deleting the user app_user from the database and re-creating, exactly as I did in the beginning:
CREATE USER 'app_user'#'xxx.xxx.xxx.xxx' IDENTIFIED BY 'mypassword';
GRANT SELECT ON mydb.* TO 'app_user'#'xxx.xxx.xxx.xxx' IDENTIFIED BY 'mypassword' REQUIRE SSL;
FLUSH PRIVILEGES;
I'm not sure if the DB server IP change is just a coincidence, and maybe there's some other issue.
The entry for app_user in select user, host from mysql.user shows the same IP address as in the Access Denied message above. For what it's worth, I tried changing the DB user host to * and got Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server.
Could this have something to do with SSL being required by connection attempts from this user?
The problem was related to the REQUIRE SSL in the privileges for my user. Without it, I could connect just fine. I got things working again by putting my client-cert.pem and client-key.pem files on the application server, updated my.cnf by adding:
ssl-cert = /path/to/client-cert.pem
ssl-key = /path/to/client-key.pem
...under the [client] section and restarted the mysql server.
However, I still don't understand why I was able to connect successfully before when I had done none of these things.