I have a mysql database on an unmanaged rackspace cloud server. I can connect to phpmyadmin with no issues. I checked if port 3306 is listening and it is. /etc/mysql/my.conf shows bind-address = 127.0.0.1.
When I use navicat to connect via ssh, it says SSH tunnel: Invalid username or password! I've reset my passwords and restarted mysql and the server just to make sure but I still can't connect. What can I try next to get this working?
Please connect to MySQL and run
SELECT USER(),CURRENT_USER();
What does this output ???
USER() reports how you attempted to authenticate in MySQL
CURRENT_USER() reports how you were allowed to authenticate in MySQL
If the output of these two functions do not match, you will need to create a user that matches the USER() or CURRENT_USER().
If they are both root#localhost, please run
SELECT user,host,password FROM mysql.user;
Now, visible compare if all root users have the same password.
Also, please check the contents of /etc/hosts on the server.
This not fully an answer, but I hope this helps !!!
Related
I'm facing some issue when installation in MySQL-Server. I tried to change the root password several times but it does not work as I expected. Finally when I'm going to change the password It's shows like this kind of output. How can I resolve this problem. When I going to connect to the sql database using netbeans it's output shows this error.
Cannot establish a connection to jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=CONVERT_TO_NULL using com.mysql.cj.jdbc.Driver (Access denied for user 'root'#'localhost')
mysql > select user, authentication_string plugin from mysql.user;
I think that you have correct password, but NetBeans cannot connect to TCP port 3306 at all. As soon as JDBC driver cannot connect to unix socket, please try to bind MySQL Server to tcp port 3306.
I think that it will be enough to check your MySQL configuration and find "skip-networking" option and remove it.
Please check /etc/my.cnf.d directory and /etc/my.cnf file for this line, delete it and restart MySQL server.
If you need to change the root password, the easiest way is to run mysql_secure_installation script from root user.
I can't connect remotely from Nodejs to a MySQL database from a domain. I've searched a lot, my ip is listed in the host list, and I've also checked the MySQL variables and the bind-address is set to *.
And, also, does anyone know why when I try to add a new host for remote mysql connections it says that the % wildcard is not allowed?
With another domain it works just fine.
Please help me figure it out.
Thanks!
You need to check if the port is open from remote by using MySQL workbench or other clients. You can also use telnet in the command line:
telnet {database ip} 3306
If you got a timeout, It seems there is a Firewall or Mysql config not listening remote IPs so call your ISP or hosting provider and ask them for open access.
But if you got "access denied" message or telnet connection was successful, we have something wrong in MySQL user privilege.
I know there are a million questions like this where the answer ends up being that the user forgot to use the correct password, or didn't know to connect to 'localhost' as the DB server or something stupid. This is not one of those questions.
When I SSH into my server from a terminal, I'm able to connect fine. From there, I can run:
mysql -h localhost -u MyUser -pMyPassword
I can get into the DB just fine from the terminal.
Using Navicat, I've set up an SSH tunnel. I've done this a thousand times before and know exactly how it works.
On the SSH tab, I put in the REMOTE hostname. Port 22. Username is the username that I use to SSH, NOT the database username. I've used both a password and a public key. Both work fine.
The problem seems to be the connection to the database after the SSH tunnel is established.
On the general tab, I have the hostname set to 'localhost'. The username is MyUser, the same username which works with the mysql command in the terminal. The password is saved, and is MyPassword, the same password which works with the mysql command in the terminal. The encoding is set to UTF-8, the default.
I've double-checked all these values a thousand times, they match exactly what works from a terminal.
The error I get is:
Access denied for user 'MyUser#127.0.0.1' (using password: YES)
It's clear from this message that the SSH tunnel works, but the connection to the database does not. Again, the values on my general tab match the values I use in the mysql terminal command (which works) exactly, but Navicat won't connect.
I've also tried using 127.0.0.1 as the host. This produces the exact same error. It's curious to me that setting a hostname of 'localhost' throws the error with 127.0.0.1 instead of localhost, but I assume this is just set up in the server's host file and is essentially the same thing.
I've tried this with 'Use Compression' both checked and unchecked, though unchecked is the default value.
I've also double-checked my general tab against the configuration in a webapp which runs off the server, and it is identical. The only things I can think are:
-MySQL is not running on port 3306 (though I wouldn't expect an access denied error if no server existed on this port to begin with).
-UTF-8 default encoding is incorrect (though every single table in the DB is set to utf8_unicode_ci)
Those are the only two things left which I could change, as the username and password are correct.
I also read a guide which said to check the server's /etc/ssh/sshd_config file, and look to see if there's AllowTcpForwarding set to no. This value does not exist in that file, and I was told that the default value is yes, so I haven't added the value.
It's worth mentioning that this is a MariaDB database, and I have the connection set to use MySQL in Navicat. I've successfully connected to MariaDB databases using the MySQL setting in the past, so I don't think should cause any issue.
I don't know if this is a user error on my end, or if the remote server is configured incorrectly.
I was given some connection info for a server as follows:
Server IP
server username
keyfile
mysql user
mysql password
and I can shell in and run the "mysql" command with the mysql user and password I was given, but I can't setup a connection in either MySQL Workbench or in HeidiSQL.
In MySQL Workbench, the 'Standard TCP/IP over SSH' seemed to best fit the info I was given, but when I try to connect I get "Authentication error. Please check that your username and password are correct and try again." or "Authentication error opening SSH tunnel: Authentication error. Please check that your username and password are correct and try again." in the logfile.
In HeidiSQL the "MySQL (SSH tunnel)" seemed to best fit the info I was given, but when I try to connect there, I get "Lost connection to MySQL server at 'reading initial communication packet', system error:0"
I looked up both these errors and couldn't find anything for the first one, and the second one seemed to be more about server configuration. I'm not too savvy with server config, so I'm a bit stuck evaluating whether or not I'm doing something wrong on my end, or if something needs to be changed on the server. I'd appreciate some advice. Thanks!
You must be more specific about the credentials you got. Is "server IP" the IP address of the MySQL server or an SSH server? Is the "server username" the SSH user or something else (e.g. a regular user of the target machine)? In my tutorial video on Youtube I explained what you have to use where to create a connection, including SSH connections: https://www.youtube.com/watch?v=DCgRF4KOYIY
You have to check a couple configuration steps before you can perform a remote mysql connection:
First of all you must check that mysql default port(3306) is listening on the correct interface.
You can check this out using netstat command in the remote server:
# netstat -tulnp
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1111/mysqld
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Then you must check that the remote host is allowed to perform querys into mysql engine (you must check user and host permissions over your database).
Connect into terminal and run the following command in mysql prompt:
mysql> select user,host from mysql.user;
Check the following link to deep insight mysql user and hosts system:
https://dev.mysql.com/doc/refman/5.0/en/adding-users.html
Check user,host permissions over your database:
mysql> show grants for root#localhost;
https://dev.mysql.com/doc/refman/5.1/en/grant.html
You must check that remote host (client) exist for example: user#192.168.1.2
Finally if you are using putty to encrypt over ssh you connection please check that you rsa key fingerprint is added you can perform this just logging ssh using you putty client.
I normally code on windows and using MYSQL4.1. And mysql gem version is 2.8.1. In my setup when I use mysql gem to access the MYSQL server, I give the root username and password of the sql server. And in rails db config file, I give user name as 'root' and its password and host as 'localhost'. My rails server and Mysql server are running on the same machine.
But recently I had to do a project in which I had to access the MYSQL server installed at a client site. It is a linux machine. I am not sure of the sql server's version number. To access it I was given a username and password for SSH and the root username and root password of the SQL server also. But for accessing that machine, in the mysql new method I have to specify the ssh login and user-password instead of sql user and password.
I cant access the DB if I give the MySql root user and password.
So, mysql.new(machine's public IP, ssh login id, ssh login password, db_name) works whereaes mysql.new(machine's public IP, 'root, root password, db_name) does not work. I am not sure, I understand what is happening. So, my question is can anyone explain this login behavior? Why cant I access the mysql server with the sql server's root login and root password.
To expand a little bit on what adamaig said:
When you're logged into the MySQL console as root, do this:
use mysql;
select User, Host from user;
MySQL should give you a table with the accounts and their respective hosts. You'll probably see that root can only log in from '127.0.0.1' or 'localhost'. You'll also probably see another account with credentials identical to those of the ssh account that was given to you.
Also, I would advise against giving root permission to log in from everywhere, it is a security risk.
But, if you ssh directly into the machine (using something like PuTTY if you're on Windows), you'll be able to log in as root from there.
Sounds like you need to create a user in the remote db that allows remote login. The root account is typically not given permissions to login from '%' . Try looking at the mysql.user table to see what the permissions are. Then you might want to look at the mysql.com developer documents on setting up accounts and security. The answers there will be fuller than can be given here.