MySql server not showing proper databases from Ubuntu server - mysql

I'm using wsl2 on a windows machine. I want to view my databases that I have on mysql server ubuntu in a GUI such as mysql workbench (on windows) but it seems as the two are not linked. In the pictures provided you can see that when I login to root, it displays different databases, I also use different passwords for root on both servers. When I try to use the root password from the ubuntu server in workbench, I get the error that I cannot connect to the database server.
Ubuntu databases
MySql workbench databases
MySql workbench config
MySql workbench error

UPDATE 2022
I found myself in this same need, and found a good resource that tackles this issue rather nicely. The solution itself predates even this question, funnily enough.
Long story short, check the following GitHub repository. Instructions are available and I can confirm it works on Windows 10.0.19041.1415 and WSL2.
https://github.com/shayne/go-wsl2-host
========================================================
WSL doesn't use the same IP as Windows, meaning you can't access it using localhost. Also, WSL IP changes everytime you boot it, meaning that the credentials for the connection will work only once.
In the sister community SuperUser, this has been discussed and some workarounds are avaliable, but I can't tell if they will work specifically with MySQL Workbench, as they ofter require you to use PowerShell/CMD.
Please, refer to the following discussions, which also provide further sources on the topic (There is one in particular that might be useful if you are running Windows 10 Pro).
Make IP address of WSL2 static
localhost and 127.0.0.1 working but not ip address in wsl windows 10
There are several requests to allow us to set WSL IP statically, so we can register it as a host in Windows DNS Host file and use that alias instead of the IP while setting up a connection (or use the IP itself, since it would be static anyway), but it is not ready yet AFAIK.

After reading the answer from #Jetto, I thought you could create a batchfile like this:
#ECHO OFF
wsl export wsl=$(hostname -I); sed -i -e "s/172.[0-9]*.[0-9]*.[0-9]*/${wsl/ /}/g" /mnt/c/Users/*username*/AppData/Roaming/MySQL/Workbench/connections.xml
This will replace the ip-address to the current ip-address of your wsl instance (relying on the fact that is starts with 172.)
If you start MySQL Workbench after running this script, you should be able to connect to MySQL (or MariaDB) which is running in the WSL2 session.
Disclaimer: I am not responsible for the fact that you did not make a backup of the file connections.xml 😉
P.S. In case you wonder: Yes this instance on my computer uses port 3356. But 3306 should work too if you do not have a local MySQL running.

Related

how to change Mysql server hostname

I run my service in docker-compose. And MySQL host name is “mysql”, when I develop in my computer, MySQL host name is “localhost”.
Now I want to change my computer MySQL hostname to “mysql”. So I can connect MySQL on my computer by mysql+pool://root:password#mysql/test_db.
Please help me, I find solution spend lots of time.
It is recommended to separate this connection string setting to an environment variable.
If you really want to use mysql, you can modify your OS's hosts file (e.g. for macOS or many linux distros, it should be /etc/hosts).
and put 127.0.0.1 mysql at the end of the file.

MySql workbench not responding w local server

I have been using MySql Workbench to connect to a local MySql server and to remote MySql Servers. The last couple of days the Workbench freezes when I connect to the local version. It still works for the remote servers.
I am using workbench 6.3.4 and then tried 6.2.5 just to see if it is a version issue.
I also can access the local MySql instance using HeidiSQL.
Any recommendations on what to look for?
Update
The advice to recreate the connection solved the issue. I just created a new one and it works fine.
A couple of things you can try:
Try restarting the sql server (remember, workbench is just a utility for accessing a db, it does not host the database for you)
See if you can access mysql on the command prompt / terminal, the command for mac & windows
(once you navigate to the mysql folder, try the command:)
mysql -u root
(if you have a password-protected account, the command will be
mysql -u someuser -p
If the above doesn't work, mysql is either offline or denying you access (depending on response), and you'll need to setup the server / assign privileges.
If all else fails, it may help to try another version of SQL / Workbench (for a easy-to-use sql sever setup, I'd recommend WAMP or MAMP, assuming you want a HTTP server bundled with it)
Additionally, it may help to recreate the local connection in workbench (of if your getting regular crashes, reinstall & update workbench). Good luck with it.

How to show different databases MySQL workbench?

I downloaded MySQL, and installed it correctly.
When I started the MySQL workbench it shows me these databases (I don't remember all of them):
sakila
test
world
It is ok, they are work, I can access them with no problems. But later I installed xampp, after that when start MySQL workbench it shows me different databases:
cdcol
phpmyadmin
test
webauth
I can't access the previous databases.
How to switch between them?, or
view them all?
Not sure whether xampp uninstalled your first server, but it is more likely that its installation changed the default MySQL TCP/IP port (3306). Maybe both servers try to run on the same port (which doesn't work) and one failed to start (in this case the first installation).
So what you need is to make each server run on its own port. You can use MySQL Workbench to make the necessary change. However first you need to check if still both servers are installed. Do you have 2 MySQL services running? Switch off one of them and connect with MySQL to the running server. If that works shut this down and run the other service. Connect again with MySQL but this time go to the admin section, config file, and change the port to e.g. 3307. Save and restart the server (all within WB possible). Now you should be able to run both servers at the same time (provided the first one runs still on the default port). Create a second connection and server instance in WB so that you can access one server at 3306 and the other at 3307
If there's only one MySQL service entry then xamp has removed the previous installation and you must install it again if you really need two servers.

Connecting to a database without remote connection

Due to security considerations from my provider, I am not able to MySQL Workbench to connect to my database. The only way to access my database is to use phpmyadmin. Because I'm used to use MySQL Workbench and their tools, it is for me much easier to maintain my database. Using phpmyadmin is annoying, so I'm googeling a solution to use anyway MySQL Workbench. Is there a way to break this security consideration or to connect MySQL Workbench through phpmyadmin to gain access to the database?
If your hosting provided did it recently then I am pretty sure it is must be a response to this terrible security flaw discovered in mysql last month. The attack is as simple as running that one line shell command.
Not all OS/MySQL combinations are vulnerable. In case your hosting company was, then for a few moments - all customers
logins were at stake (including the root login).
To answer your question, unfortunately you can not do much in this case. You cannot do any port forwarding tricks even if you have shell(ssh) access because normally port forwarding isn't allowed in shared hosting environments.
In case you want to try, you can run this command on a unix box
$ ssh -L 3306:localhost:3306 username#yoursite.com
If you can login and don't see any errors related to port forwarding, perhaps your can direct your workbench to localhost on port 3306 and theoretically it should work.
If you are using windows you can use putty to do port forwarding as described here.
I think no. Only changing table Users in MySQL you can access from other IPs and hosts. And this table is not accessible by other users.

MySQL remote connection slow even after enabling skip-name-resolve

I have a development environment set up with remote access to a shared dev database.
I'm experiencing VERY slow response time from the remote MySQL server. I've added skip-name-resolve to the my.cnf file, restarted mysqld, and also verified that it is indeed, turned on via 'show variables' at the mysql command line.
Interestingly, if I connect to the command line interface remotely via
mysql -h IPADDRESS -u USERNAME -p
All commands are executed lightning fast.
Select * on a large table comes down the pipe instantaneously.
I'm wondering why the CLI would allow immediate response, but the php connection in my application waits 8-10 seconds before returning any data from the remote MySQL server. It's an Amazon EC2 instance, and it's the Amazon linux ami, seems to be similar to CentOS. Any ideas?
Thanks!
I've just solved same problem I was having, took me 4 days.
Apache was ok
MySQL was ok too
Problem was in my script - gethostbyaddr();
when accessing web server on the localhost is fine.
But when accessing the server from another computer takes ages, so for now I have commented out gethostbyaddr() and it is fast as if run from localhost.
I am guessing gethostbyaddr() is some sort of Windows DNS issue which I'll look into later
I'd start by determining where the slowness comes from. Is it in establishing the connection when you open the db, or is it in returning the results from the select, or both? You don't say what version of PHP you're using or what version MySQL is running on the server. My money would be on that specific combination being problematic. Make sure you're running the latest updates on your AMI.