Unable to access my off site MYSQL DB via a VSCode extension when it is running under WSL2 - mysql

I'm running Windows 11. I have my dev environment in Debian running via WSL2.
I have this VSCode extension installed (although I have tried multiple SQL VSCode extensions and they all act the same)
If I have a VSCode window open in a WSL2 instance I am unable to connect to my DB but if I have a normal VSCode window open I am able to use any extension to access my DB.
In both instances the DB connection details are identical.
I need to use a program called ScaleFT to create a secure tunnel to the DB, I'm assuming this is the cause of the issue in part.
I am able to connect to my local dev MYSQL DB running in docker from both a WSL and normal VSCode window.

I've found that WSL's network sharing with the host system seems to run into trouble a lot with VPN and Ad-Hoc tunnel sharing with the Windows host.
What worked best for me was just to install an independent client for the WSL host. I use Ubuntu personally but I bet this will be a drop-in for your Debian setup, too.
Add the ScaleFT Repo to apt:
echo "deb http://pkg.scaleft.com/deb linux main" | sudo tee -a /etc/apt/sources.list
Add the ScaleFT signing keys to your local keyring:
curl -fsSL https://dist.scaleft.com/pki/scaleft_deb_key.asc | gpg --dearmor | sudo tee /usr/share/keyrings/scaleft-deb-key.gpg
Pull package list and install the Linux tools:
sudo apt update && sudo apt install -y scaleft-client-tools scaleft-url-handler
That should leave you with a ready copy of the sft client tool. You can test with:
sft --version
From there, you can enroll your new WSL client and those connections should start working for you but, of course, your mileage may vary!

Related

How can I connect to MySQL from Perl?

I am trying to create a login page for a website using perl CGI. In an already existing script the database handle is connect("DBI:mysql")
When I run the command
$ mysql -u root -p
The linux server shows command not found.
I am new to modules DBI and CGI in perl. So i am confused if mysql does not exist on the linux how should i create a database and connect to it using DBI?
There could well be many steps to get through here in order to get this all working.
But, question one is: which platform are you running on? Your command prompt makes me think it's Linux, but which distribution and which version of that distribution.
It looks very much like you don't have the MySQL client packages installed. The easiest way to do that will depend on your answer to question one.
On a Debian-based system (which includes Ubuntu), you can run:
$ sudo apt-get install mysql-client
On a RedHat-based system (which includes things like Fedora and Centos), you can run:
$ sudo yum install mysql-client
If that last command tells you that yum can't be found, then try:
$ sudo dnf install mysql-client
Once you have the client installed, we can move on to the next step :-)

how to use my database on AWS

I'm using linux, and I've been trying to import my database mysql to my AWS instance, I downloaded all the tools.
php, mysql-server,apache2 and the AWS instance is running.
I'm using FileZilla to upload the files, and I'm connected to the server fine, but whenever I try to open myphpadmin it won't work, showing me weird things on the screen.
Adding a pic for reference
It's not about the AWS; you should prepare the LAMP env at first.
To install and start the LAMP web server with the Amazon Linux AMI
sudo yum update -y
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
sudo service httpd start
sudo chkconfig httpd on
For more info read the following article
Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

Connection time out installing mysql server in unix

I am trying to install mysql server in my AWS EC2 instance. I googled and executed the below command in the shell.
sudo yum install mysql-server
It throws the below connection timed out exception
Loaded plugins: priorities, update-motd, upgrade-helper
http://packages.us-west- 2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: [Errno 12] Timeout on http://packages.us-west-2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: (28, 'Connection timed out after 10001 milliseconds')
Trying other mirror.
Is this the right way to install mysql server?
Thanks.
installing mysql
From the current AWS EC2 documentation:
To install and start the LAMP web server
Connect to your instance.
To ensure that all of your software packages are up to date, perform a quick software update on your instance. This process may take a few minutes, but it is important to make sure you have the latest security updates and bug fixes.
Note
The -y option installs the updates without asking for confirmation. If you would like to examine the updates before installing, you can omit this option.
[ec2-user ~]$ sudo yum update -y
Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages. Use the yum groupinstall command to install multiple software packages and all related dependencies at the same time.
[ec2-user ~]$ sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
Note
Non-Amazon Linux instances may have subtle differences in their group names. If the above command fails because of an invalid group name, use the yum grouplist command and scan the output for similar groups, such as "MySQL Database server" instead of "MySQL Database", and use the appropriate group name for your distribution.
Install the php-mysql package.
[ec2-user ~]$ sudo yum install -y php-mysql
I suppose you only need to install mysql, so you just need to run the 1st command, adapt the second to only grab mysql from the repositories, and skip the last one:
[ec2-user ~]$ sudo yum update -y
[ec2-user ~]$ sudo yum groupinstall -y "MySQL Database"
Depending on which version of linux you have installed (Amazon, Red Hat or CentOS), you may need to change the string "MySQL Database" to something else. The following command:
[ec2-user ~]$ sudo yum grouplist
Will list all the possible group install you may perform, so you need to filter it to get the right string:
[ec2-user ~]$ sudo yum grouplist | grep -i mysql
And choose the most appropriate one in that filtered result set.
network connectivity
Now, regarding your specific issue, the FAQs describes your problem as follow:
If the AMI cannot access the yum repositories, it will timeout and retry multiple times before completing the boot procedure. Possible reasons for this are restrictive firewall settings or VPC settings, which prevent access to the Amazon Linux AMI package repositories.
If you encounter this issue you can either modify your environment so that the Amazon Linux AMI can connect to its package repositories [...]
Unfortunately, no explanations are given as yo how you can change your environment to enable connectivity.
Apparently, by using the dashboard, you should be able to open outbound access to the port the yum servers are using:
AWS dashboard > ec2 > security groups > default group > outbound rule: ??? (HTTP*) 0.0.0.0/???
The usual port for yum server is 80, so just replace ??? above by 80 to have access to the repos. You also should replace 0.0.0.0 with the actual repository server address.
If this solution does not work, you might also try disabling the firewall altogether for the duration of the update:
[ec2-user ~]$ sudo /etc/init.d/iptables stop
<...Update commands as listed above...>
[ec2-user ~]$ sudo /etc/init.d/iptables start
Or
[ec2-user ~]$ sudo /sbin/service iptables stop
<...>
[ec2-user ~]$ sudo /sbin/service iptables start
I just delete all the files in /etc/resolv.conf dir

php5-msql installed on Ubuntu but not shown in phpinfo.php

I am setting up Nginx+PHP+MYSQL on Ubuntu 12.04.
I used
apt-get install php5-mysql
to install MySql module for PHP. However, everything seems to be installed and enabled, it is yet shown in phpinfo.php and I cant get the php application to connect to the MySql server. The php app is accessible, and I can view things on phpinfo.php.
BTW, mysql is running normally, because I am running an Rails app using it, so I know it is working fine.
As #vstm said a quick summary to help others get the answer quicker:
1. Kill php-cgi
killall php-cgi
2. Restart php-fpm
/etc/init.d/php5-fpm restart OR service php5-fpm restart
3. Double check with
grep -E 'extension=(pdo_)?mysql.so' -r /etc/php5

Getting MySQL working on OSX 10.7 Lion

I'm currently trying to get MySQL working on OSX 10.7 Lion. I tried the brew way:
brew install mysql
-> cmake -> no problems
-> make -> no problems
-> make install -> no problems
-> done
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Installing MySQL system tables...
/usr/local/bin/mysql_install_db: line 428: 15397 Done { echo "use mysql;"; cat $create_system_tables $fill_system_tables; }
15398 Done(141) | eval "$filter_cmd_line"
15401 Segmentation fault: 11 | $mysqld_install_cmd_line > /dev/null
Installation of system tables failed! Examine the logs in
/usr/local/var/mysql for more information.
Did anyone get mysql to run on Lion?
You can download a MySQL installer as a DMG file, complete with an installer, system preferences pane and a startup script directly from MySQL. Go to MySQL's community server download page, select Mac OS X as the platform and pick the DMG file.
You can skip the registration form (there a little link under the signup form) and you should be on your way.
Once the file is downloaded, double-click on the DMG, launch the installer and complete the installation. After that, install the startup script using its installer and finally the preferences pane by double-clicking on it. I highly recommend choosing to install it for all users on the computer.
You'll find this way much easier than compiling from source.
You should check out Sequel Pro if you need a great OS X tool to manage your MySQL databases.
A drop in replacement for mysql is mariadb. You can install with 'brew install mariadb'. It builds on Lion.
Existing mysql drivers and clients just work. I'm using it with python-mysql and django.
It's even called mysql so you won't even know the difference.
Ha! Got it!
First... download mysql-5.6.2 here: http://dev.mysql.com/downloads/mirror.php?id=402349#mirrors ... once finished, untar the file and do this:
mv path/to/mysql-5.6.2-m5-osx10.6-x86_64 /usr/local/mysql
echo "PATH=\$PATH:/usr/local/mysql/bin" >> ~/.profile
# open a new tab
cd /usr/local/mysql #this is essential!
./scripts/mysql_install_db
mysqld_safe &
mysql -uroot
works for me :)
You need to set up your path environment too, and it's also good practise to set a root password while you're at it. I've created a full step-by-step here: How to install MySQL on Lion (Mac OS X )
All,
I was having issues with connecting to my DB through Tomcat, yet could through the MySql tool. Tomcat was accessing it through the actual IP of my machine (10.0.x.x) instead of through localhost or 127.0.0.1. Turns out that when I migrated from SL to Lion, remote connections were disabled. Once I enabled them, it worked fine.
Hopefully this helps someone.
I had MySQL installed already, but after upgrading to Lion it would no longer start.
I tried installing the latest official version and it still wouldn't start.
Finally, this fixed it:
$ sudo mkdir /var/log/mysql
$ sudo chown mysql:mysql /var/log/mysql