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
Related
I'm having trouble logging in remotely to mysql.
I've set up a user (open_user) without a password and I want to be able to connect with it to my db (open_db) from any remote server (yes I know its a security nightmare but I'm testing something out).
I can log in successfully from the local server:
mysql -openuser open_db
And when I view the grants for this user:
show grants for openuser
- I get this:
GRANT USAGE ON *.* TO 'openuser'#'%'
GRANT ALL PRIVILEGES ON `open_db`.* TO 'openuser'#'%'
My understanding is that this user should be able to log in from any server.
However when I try this:
mysql -uopenuser -hmyserver open_db
I get this:
ERROR 1045 (28000): Access denied for user 'openuser'#'xxx.xxx.xxx.xxx' (using password: NO)
I've also tried setting bind-address in /etc/mysql/my.cnf:
bind-address = 0.0.0.0
Any ideas?
Follow this steps
Open Database Users for MySQL
Edit your user(openuser)
Write to Host %
This will give permission for all IP address for your user.
you can use this,
mysql -h host -u username -p password
I actually thought I could do this until I tried. I installed MySQL server on one PC in the Local network IP Address (192.168.1.4) and now I am trying to access it from another PC in the same network (192.168.1.5) but I am unable:
C:\Users\DOMICO>mysql -u domico -h 192.168.1.4 -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'domico'#'DOMICO-PC' (using password:
YES)
Surprisingly DOMICO-PC is the PC I am trying to connect from. Why is it not connecting to the given host but trying to connect to Local machine?
You need to give permissions to connect from remotehost
mysql>GRANT ALL PRIVILEGES ON database.* TO 'username'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
You need to have proper permissions to connect. In the computer that has the DB installed, give your user the proper permissions:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'domico'#'DOMICO-PC';
mysql>FLUSH PRIVILEGES;
You can read more here:
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
And here:
https://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html
This is connecting to the intended host as you require it to. t is just stating who is connecting. and where from.
USER#DOMAIN
user : your user running the mysql command
domain : name of the system you are connecting from.
Log into mysql via the server using -u root, ensure the user 'domico' is created and has sufficient access.
creata a new user by mysql server
and give it privileges you can do it by command and by using any server e.g by using workbench
For all users and all host.
mysql -u root -p
GRANT ALL PRIVILEGES
ON *.*
TO '%'#'%'
IDENTIFIED BY 'password'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT;
MySql is installed on a Ubuntu server.
I am running Windows 8.
Logging in through Putty. I can log in to database with both root and webadmin user accounts.
I can also log in through my browser, using <server ip address>/phpmyadmin
My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.
commandline:
mysql -u webadmin -p
or
mysql -u root -p
error 1045 (28000): access denied for user 'webadmin'#'localhost'
(using password: yes)
I added an iptables entry to allow mysql and that didn't work.
Also, the firewall on server is inactive.
You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html
You can run the following (but be careful as it will leave your DB open)
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above
CREATE USER 'root'#'%' IDENTIFIED BY PASSWORD '[your password]';
I want to connect to my SQL Server on my remote server. I have installed MySQL on this server with apt-get and set up all necessary details. On the server everything works fine. When I want to connect with the MySQL Workbench, I cannot connect with any user at all.
I logged into MySQL in Ubuntu and created a new user first:
CREATE USER 'username'#'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'#'localhost' WITH GRANT OPTION;
CREATE USER 'username'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
I opened the my.cnf file:
port 3306
bind-address 127.0.0.01 (DO I NEED HERE MY REMOTE SERVER IP?)
service mysql restart
My questions would be:
1) why is the host 127.0.0.1 on my remote server?
2) In the workbench connection setup: which hostname is correct? my server IP or 127.0.0.1
3)I get the message: Failed to connect to MySQL. Access denied. So I think the user is the issue?
4) Do I need to change the cnf?
Thank you.
After you create the user and configure the right permission did you
FLUSH PRIVILEGES;
After you change your my.cnf did you restart Mysql?
Stop and Start from XAMPP Panel control
Change
bind address=127.0.0.1
to
bind-address=YOUR-SERVER-IP
I am able to connect to mysql through a gui workbench but when i try to connect with my applications datasource (which runs on tomcat) i get:
Access denied for user 'dbuser'#'192.168.100.231' (using password: YES)
i have tried all the options in the mysql reference guide but none worked.
any ideas?
You should grant access to remote machine. Connect to MySql as root and do this:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'IP' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Instead of IP you may use host you remote machine.