Is it possible to connect mysql of my webhost from cmd on my pc, in the same way as I am connecting to mysql installed on my localhost using XAMPP.
You'll need to download and install the Windows MySQL client
http://www.mysql.com/downloads/installer/
After installation, make sure the mysql executable is in your cmd PATH.
You need to specify the hostname or IP address of the server with the -h parameter.
mysql -u username -p -h myhost.example.com
Yes its possible to connect to MySQL on web host. MySQL runs on port number 3306. You need to check if the web host has this port open. if not you can request your hosting provider to get it opened. Once its done you can connect to MySQL as you do on localhost May be you need to add privileges to user account to connect from remote machine(your localhost IP).
Other option would be to use PhpMyAdmin.
Related
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 have visited many websites for remote connection of MariaDb.
I have executed the command as below to create user with password in sql.
GRANT ALL PRIVILEGES ON . TO 'root#(my server ip)' IDENTIFIED BY '(my password)'
And i've added one line below [mysqld] in the file of /etc/my.cnf.d
bind-address = 0.0.0.0
Then restart MariaDb service as below
sudo systemctl restart mariadb
Everything runs good.
However when i access by below command, it runs failed.
mysql -u root -p -h (my server ip)
I've turn off my firewall in my server, and turn on the port 3306 in GCP server, and it can be expected, i must fail to connect in my local machine.
Since you want to use a TCP connection, I assume that you want to connect to a remote server, not to a server running on the same machine.
Make sure that you are able to connect physically to the database server, e.g. with telnet server_ip:3306.
Determine the IP address of the computer from which you want to connect to the server (= client_ip).
Add a user on the server:
GRANT ... TO root#client_ip
If client and server are running on the same machine, the preferred way is to use a linux socket (user#localhost) which is way faster.
I am trying to connect HeidiSql from the host to my WSL Mysql but I could not get it to connect it
Error "can't connect to Mysql server on '127.0.0.1'"
Tried SSH too but could not connect to the server
I'm also hosting mysql-server on WSL and running MySQL workbench on Windows.
I had to get the IP inside of WSL
And use this IP in MySQL Workbench
By default, MySql only listens on 127.0.0.1. If you are connecting using the IP address returned by wsl hostname -I (as mentioned by Permana) then you need to change /etc/mysql/mysql.conf.d/mysqld.cnf to listen on all IPs or your specific IP.
Edit your MySql config by typing this in your Ubuntu instance:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Change the line:
bind-address = 127.0.0.1
To:
bind-address = 0.0.0.0
or change 0.0.0.0 to the IP returned by wsl hostname -I.
Restart MySql using: sudo service mysql restart
Since your question is asked before WSL2 release, I assume you were using WSL1.
For WSL1
You can access WSL1 MySQL directly from Windows, but you were attempting access in a wrong way.
In the Network type, you should choose MariaDb or MySQL(TCP/IP) instead of MySQL (SSH Tunnel).
For WSL2
Check this WSL github issue. Save #edwindijas's powershell script and execute it by administrator. If you still cannot access MySQL and got access denied for user ... <you-computer-name>.mshome.net, you need to allow this user access from this host.
For example: let's say root, you need execute this in mysql cli:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%<you-computer-name>.mshome.net' IDENTIFIED BY '<password>';
Or allow root user access WSL2 MySQL from any host:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
As for me who's also using WSL for making web based application
first make sure mysql is running on WSL like sudo service mysql start
then once started, open HeidiSql and simply connect to it, here the example on my part
make sure the IP address is 127.0.0.1 not any IP, not your IP used to connect on the internet
I have a ubuntu 16.04 on which I run 3 servers from virtualbox (a webserver, a home file server and a mysql server).
In this mysql server I naturally have an internal ip (192.168....) and an external one.
However when I try to connect remotely to this mysql server from mysql shell, workbench or .NET connector (eg. mysql -u root -p -h 172.241.442.12) using the external IP of this virtual machine I always get ERROR: Not connected.
My question is whether to connect I have to enable port forwarding in my router (3306), just as I would do enabling 80/8080 in a webserver to make it accessible from the internet.
I never did it before and haven't find any clear tutorial either. My main purpose is to connect to this db in a vb.net application.
Thanks!
Yes, if you intend to access it in this manner you will need to forward a port. You will also need to grant access to MySQL for a user that is allowed remote access.
GRANT ALL ON somedb.* TO `user`#`123.123.123.123` IDENTIFIED BY 'somePassword'
The IP address can be a hostname, or % to match everything.
That said, unless you really need a permanant external connection to MySQL you should not expose it like this, the better option would be to tunnel the port through SSH.
ssh -N user#dbserver -L12345:localhost:3306 &
mysql -u root -h localhost -P 12345
I've looked around, and can't find any answers that specifically address what I'm wondering:
In the Mac terminal, I can access a remote server through ssh:
ssh [my_username]#[server.host.com]
which prompts me for a password, and after I enter my password, it brings me to the remote server.
Once I've logged into the remote server, I can access MySQL:
mysql -u [other_username] -h [mysql.host.com] -p
which prompts me for another password, and after entering the password, I'm in the MySQL console and can show databases located there, etc. We can call the database I'm interested in [database].
My question is, how do I hook up Django, run on my localhost, to [database], so that my app uses that [database]?
You can create an ssh tunnel to map the remote server mysql port to a local port on your machine.
ssh -L 3333:127.0.0.1:<remote mysql port> <username>#<remote host> -N
Whiles this process is active the local port 3333 will connect to the remote port on the remote host.