I installed MySQL Server 8.0 on Windows Server 2019, during installation I created user 'superna' # ' %' with DBAdmin rights. When connecting from a local machine, there are no problems (mysql -u superna -p), but when trying to connect from a remote machine (mysql -h 10.165.1.20 -u superna -p), error 1045 is returned.
I checked the availability of port 3306 using nmap, port is open.
When installing mysql server on Windows 10, such problems are not observed, the connection from the remote machine works correctly. Can you tell me what point in the settings I might be missing?
Can you confirm if your my.cnf file have this line? If it hasn't, add it and restart mysql.
bind-address = 0.0.0.0
Problem solved. The server was configured to NAT port 3306 to another machine on the network.
I have Installed MySql 8.0 Version in a windows
server and able to connect via WorkBench/MySql shell locally.
I would like to access MySql from a remote windows server.
Here are the things I have tried.
1) Created root#% user and Grant full access to the new user.
2) Created a new user as test#'remoteserveripaddress' and Grant full access to the user.
3) Opened port 3306 on Both Remote and MySql server.
4) Added "bind_address=*" in my.ini file and restarted the MySQL80 Service.
I am running out of options.
Error: I am getting below error
Failed to connect MySql at UserName#hostipaddress:3306
SSL connection error: error:00000000:lib(0):func(0):reason(0)
No matter how many different ways I try.
Not sure what am I doing wrong ??
Try to execute below command in your terminal :
mysql -h server -P 3306 -u root -p
If you successfully connect to your database, the same thing has to happen with Mysql Workbench.
If you are unable to connect then I think 3306 port is acquired by another process.
Find which process running on 3306 port. If required, give admin privileges using sudo.
netstat -lnp | grep 3306
Kill/stop that process and restart your MySQL server. You are good to go.
Execute the below command to find my.cnf file.
mysql --help | grep cnf
You can change MySQL port to any available port in your system. But after that, make sure you restart MySQL server.
I'm using Linux and I recently downgraded MySQL to 5.6 from 5.7 (due to some issues because of its strictness). Now when I use command mysql, I get the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I have checked several posts and systemctl mysql startseems to work. But everytime I reboot my system, I have to use systemctl mysql start again to start MySQL.
Also, service start mysql doesn't work.
There is no /etc/my.cnf file, only /etc/mysql/my.cnf file. I'm using Ubuntu 16.04.
How can I configure it so that the MySQL service starts at boot?
Edit:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
This post is unable to help either.
Basically, if mysql command is running without a host, it looks for a socket file on your local machine (this lets it connect to the running process directly). You have two workarounds. One is to include host in your mysql connection command mysql -u root -p -H 127.0.0.1, the other is to modify my.cnf to include:
[mysqld]
socket=/var/run/mysqld/mysqld.sock
[client]
socket=/var/run/mysqld/mysqld.sock
see here for more.
I had installed MySQL 5.7 on my local machine and was connecting using host 127.0.0.1 and port 3306. After I restarted my machine I am unable to connect to the server. When I try to start the Windows service MySQL57 it does not start. The error message in the event viewer is Fatal error: mysql.user table is damaged. Please run mysql_upgrade. When I try to run this MySQL_upgrade through command promt it gives the error:
Got error: 2003: Can't connect to MySQL server on localhost<10061> while connecting to the MySQL server.
When I do a netstat -an, I can't see the port 3306 as available or being used by any other process.
I have tried uninstalling and installing the Server component but I get the same error through the MySQL Installer wizard.
I just installed MySQL 5.5.27 on WinXP. When I open a command prompt (Start -> Run, and type "cmd"), I can access MySQL by running "mysql -u root -p". However, when I open a Cygwin terminal and try the same thing, I get this error
$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2)
Indeed, there is no "/var/run/mysql.sock" file.
If you specify the host on the command line, this issue should go away:
mysql -u root -p -h 127.0.0.1
You can also create a my.ini that mysql will use:
echo [client] >c:\my.ini
echo user=root >>c:\my.ini
echo host=127.0.0.1 >>c:\my.ini
Then you can just type:
mysql -p
You can even add the password:
echo password="abracadabra" >>c:\my.ini
Then, just type:
mysql
and you're in!
See also https://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket
Try adding this to your command:
-h 127.0.0.1
The problem is that the mysql client default host is localhost, and it treats localhost specially, using a unix socket, which is accessed via that file, but your server may not be configured to listen on the unix socket.
However, if you access the same server via the loopback IP 127.0.0.1 it will use a TCP socket instead of the unix socket and (assuming the server is online) it should work.
Just to save few keystorkes,
Add following alias to your ~/.bashrc file.
alias mysql='mysql -u root -h 127.0.0.1'
After adding this, You can just type "mysql" in your terminal & there you go right inside mysql.
As most of people mentioned here - one of the solutions will be to use aliases. Don't like them to be honest because they are preventing me learning some really nice Linux commands :) It's just a joke. But the best way for you, as I think, will be to locate a ~/.bashrc file located in your home directory and put there:
alias mysql="mysql -h 127.0.0.1"
Don't forget that you have to restart your session in order for this solution to work or you may type bash command at the same terminal session - it will reload all your bash settings. Good luck!
P.S. I suggest you to close all other terminal windows before editing .bashrc because you may just got a read-only file. I had such issue under Win7x64
I successfully installed MySQL in Cygwin on my PC according to Rafael Hart. I created a database and performed some queries and everything worked great.
The next day when I tried logging into MySQL, I got the error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (111 "Connection refused")
Apparently, when you shutdown your PC, the services also get shutdown and do not restart on boot.
To fix the problem, I typed the following command to restart the mysqld service:
$ mysqld_safe &
Then everything started working.
Here's how to run MYSQL from cygwin
Go here:
https://cygwin.rafaelhart.com/setting-up-mysql-on-cygwin/
To begin MySQL setup run the following:
mysql_install_db
Run mysql - you'll get a firewall alert from windows if you have it active.
mysqld_safe & Immediately following that, it would be wise to run the following:
mysql_secure_installation