Ant couldn't connect to mysql (access denied), but mysql client could - mysql

I hava the next task in my ant file:
<target name="initdb">
<sql driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dtest"
userid="root" password="oksaoksaoksa" >
<classpath>
<pathelement path="./lib/mysql-connector-java-5.1.13-bin.jar"/>
</classpath>
<transaction src="./init.sql"/>
</sql>
</target>
When I run it, I see the error:
BUILD FAILED
/home/sbos/projects/texterra-tests/deploy.xml:43: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
However, I can login with such login and password with mysql client:
mysql -u root -p
Enter password: <oksaoksaoksa>
Welcome to the MySQL monitor. Commands end with ; or \g.
...
Why this happens? I've just installed mysql in ubuntu 10.10 if that matters

It happens because when you connect through localhost in the mysql client, it uses the unix socket to connect, which handles privileges a bit different, while ant connects to localhost through tcp/ip.
Try granting access to 127.0.0.1 (which is not the same as localhost as far as the mysql server is concerned)
grant all on initdb.* to 'root'#'127.0.0.1' identified by 'oksaoksaoksa';

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

Not able to enter MySQL terminal using AWS Instance

I am running an AWS Ubuntu Instance.
I have installed Apache2, MySQL, PHP and phpmyadmin.
Now I am connected to the AWS instance through SSH, but I want to execute some MySQL commands but I am not able to enter the mysql mode.
After executing the command sudo mysql, I am getting an error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Executing the command mysql, I am getting the error:
ERROR 1045 (28000): Access denied for user 'ubuntu'#'localhost' (using password: NO)
I was able to enter the mysql mode, may be I have changed something during the installation of phpmyadmin, but I am not sure.
I need to enter the mysql mode again.
Apache, MySQL databases and phpmyadmin are working fine.
What should I do to be able to enter the mysql mode to execute some MySQL commands?
EDIT
I am able to execute MySQL command directly using the SQL tab in phpmyadmin, as I have done so far, but I would appreciate a solution to my issue.
This should do the trick:
$ mysql -u <username> -p<password> -h localhost
Where both:
<username> and <password> are the credentials you use to connect to the database via phpMyAdmin.
Note: that there is no space between -p and the actual password.

mysql not able to establish remote connection

Could not able to connect to the remote mysql server using mysql workbench or direct command line.
When trying it resolves different hostname
When trying directly through command line
mysql --host=10.37.1.92 --port=3306 --user=root --password=password
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'myaapvm.local' (using password: YES)
Tried, with password and without password, no luck.
I tried to connect to 10.37.1.92 server but my mysql client try to connect to different server. The only way I can try now is directly login to the machine and do the change in my DB. I have disabled firewall in my mysql DB. Does anyone faced this issue please help.
This server running with maria DB installation.
By default root is not allowed to access the database by using a remote connection. I recommend that you create a new user that will be used for remote connections. You can do that by using the following SQL commands:
CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'#'localhost';
GRANT ALL ON *.* TO 'myuser'#'%';
FLUSH PRIVILEGES;
You also need to modify your my.cnf if you didn't do that already.
#Replace xxx with your IP Address
bind-address = xxx.xxx.xxx.xxx

Why is mysql (all the sudden) translating 127.0.0.1 to localhost internally?

I have a strange issue with mysql. I want to connect to the database using the mysql client, and since I want to force connection via TCP I do this:
$ mysql --protocol=TCP -uroot -p -h127.0.0.1
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
As you can see, the connection fails, because there is no root access defined for 'root'#'localhost'. This is true - I did not GRANT any privileges to this hostname. However I did specify the root account with full privileges for 'root'#'127.0.0.1'.
I was able to connect to the database in the past with the above mentioned command. However, now it fails. I am not sure if a system update happened in between but something must have changed.
Does anyone have a solution? I would rather not stop the database server for that if possible.
Some more background info. This is running the mysql flavor percona server 5.6 on an ubuntu 14.04 LTE box with everything up to date.

MYSQL can't start service on Windows 7

EDIT: This happened most of the times, due to power failure.
Two things which worked for me.
1. Knowing how to change root password in MySQL, and taking backup of databases.
2. Install MYSQL as service.
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install
I had done clean installation of MYSQL 5.6 few days ago.
On first day everythng was fine. I could access city and world tables.
On next day I started getting below errors. Some were I read to run mysqld at admin level.
And it solved problem, but I couldn't access city and world table anymore.
On third day. I am getting only this errors.
Note: MYSQL service running previously fine, when firewall, antivirus (avast) and apache was running.
When run on admin mode :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
When run on user mode (who is admin also) :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
Not able to start MYSQL Service from Control Panel\All Control Panel Items\Administrative Tools\Service
Error Message ; WIndows could not start the MYSQL56 service on Local Computer
Error 1067 THe process terminated unexpectedly
Regards : Msinfo
You need to use "-h" before "localhost" if you want to specify a host, otherwise just remove "localhost" and it should work fine, considering a running server on your system.
Also, MySQL server is "mysqld.exe" not "mysql.exe". mysqld (d stands for daemon) is the server which should run in background and does the actual stuff like creating tables,DBs etc. But mysql.exe just connects to the server and helps you to execute SQL queries. mysql.exe is just an interface to connect to server. If you want to know why your server (windows service in your case) is not starting, you should see the XXX.log in your MySQL server installation folder under Program Files.
try by creating the database in MySql by the respective name "localhost"
eg: create database localhost;
by doing this you can clear the below error
ERROR 1049 (42000): Unknown database 'localhost'
hope i am correct
Thanks,
Daya