Start PHPmyAdmin from putty - Server is remote - php

Bit stuck here, I have looked on here, for similar, but cant find what I need.
Have looked at how to start PHPmyAdmin via putty on here.
I have a server, which is on a network. I log into the network via Putty.
The database usual access is for example 10.32.187.100/m . This is how I used to access it before the server reboot.
I have had to restart the server. But I cannot log into the database as I believe I have to turn it on.
As it is not on a local machine I do not know how. It is a linux server, and the location of ‘m’ is /var/www/html
In ‘m’ are the files for phpmyAdmin.
Nothing has been over written. The server had to restart. Hence why I need to start up PHPmyAdmin.
Can I ask how do I turn on PHPmyAdmin via putty I the method I need to use?

try this
sudo service mysql start
sudo service apache2 start

Related

Laravel Create mysql SSH Tunnel on windows10 programmatically?

Trying to setup a local Windows10 environment for Laravel 6 and need to connect with SSH to a remote linux mysql server.
Standard configuration doesnt seem to support a way to connect with SSH tunnels, but I did find a workaround that I need help finishing.
It seems the only way to get the connection going is through port forwarding, which I am able to do with gitbash/windows terminal
ssh -i /c/Users/MyUserName/MyKeyFolder/sitemaster_ssh -fNg -L 3307:127.0.0.1:3306 linuxUser#remoteHost.com
After running that manually in terminal / gitbash, I am able to use localhost with port 3307 successfully for my database configuration in Laravel and visit my site locally
Ideally, I would like to programatically check this port before laravel tries to access port 3307 on startup as well as some type of detection for later calls and reopen only if necessary.
I used this article which lays out the basics but is unclear as to whether the command line code can only be run manually
or if can be run with a script somewhere, somehow.
Laravel MySql DB Connection with SSH
I have tried doing things like
exec('ssh -i /c/Users/MyUserName/MyKeyFolder/sitemaster_ssh -fNg -L 3307:127.0.0.1:3306 linuxUser#remoteHost.com');
as well as putting in its own script nameed port_fwd_3307.sh and then running
exec('port_fwd_3307.sh');
I can navigate to the sh file from terminal and confirm it runs and the script is calling it from the proper directory, but still, I get no connection and no feedback as to whats going on other than server actively refused (but I know its a port issue, since it resolves successfully when run manually).
I have placed that command in the bootstrap/app.php file, as well as tried it in the config/database.php and public/index.php
before laravel even starts and none of this works.
Not sure if this is possible at all, but if it is, what specific part of the framework would it need to be located in to ensure the port is forwarded prior to the database connection?

Unable to access MySql db

I have been working on php for some time. I have cloned a git repo yesterday. Just after that i am able to connect to MySQL server, access MySQL db and phpmyadmin properly. Today, I started the server and tried to access phpmyadmin from xampp control panel, as soon as I try to open it, apache port is changing automatically to 49868 and mysql connection terminates.Then, again apache changes its ports to previous states.
Any help is appreciated. Thanks in advance.
EDIT : I reinstalled everything and it worked.
Check if another application is using port 80.
In command prompt use:
netstat -aon | findstr :80
enter image description here
If windows verify if in task manager is already running XAMPP.

Is it possible to use the same MySQL database on Windows (XAMPP) and Linux (LAMP)?

I have dual boot mode with Windows 7 and Ubuntu 10.
On Windows 7 I have XAMPP installed, on Linux I have LAMP installed.
Is it possible to force the MySQL DB servers installed onto different operating systems (even though they would be of identical versions, they are different) to use the same physical files?
So in dual boot mode, independently from the fact that I ran another operating system, I would be able to use the same physical data. Sometimes I'd like to switch OS but it would be great to be able to use the same databases.
in your my.ini (in Windows it's located somewhere like C:\Program Files\MySQL\MySQL Server 5.1. It's the main configuration file for MySQL) file, you should have this line:
datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/" for example
change it in both Windows and Linux Ubuntu to point to one single physical folder (on a partition with a file system which Windows could recognize). It will work. File formats are identical.
Whether you boot from Ubuntu, or Windows 7, it won't matter, 2 different builds of MySQL will be looking for data in the same place. Once data is modified in Windows environment, you boot up from Ubuntu and the data is there, modified.
Whilst not ideal, this should be fine as long as:
You're using identical versions of MySQL on both operating systems.
You shutdown mysqld before you copy the data files across. (If you're going to be copying the data files between partitions rather than keeping them on a shared fat32 partition).
In essence, as long as MySQL is running on an architecture of the same "endianness", then the file formats should be transferable.
As a suggestion, you could just close ICQ, etc. and use the free memory to run Ubuntu within a VirtualBox virtual machine on top of Windows 7 - hence ensuring you can trivially access your development environment without having to restart, etc.
This is actually quite a nice set up as it means you can use a Windows development environment if you want and simply host the site web site data on a Samba mount on the Ubuntu virtual machine.
As long as the data is sharedable/reable/writeable on both OS, and both file format are identical on both OS, it should be doable
The first problem I can imagine is the case insensitivity in windows.
so, convert your database/table ti camel_case (or camelcase) if you are always using CamelCase.
More information to read up - http://dev.mysql.com/doc/refman/5.0/en/limits-windows.html
Of course you can.
But I dont think, it is possible for your dual boot system.
Lets assume, your MySQL server is installed under Win7 machine. You can perfectly access it from Win7 enviroment, and even from Linux enviroment (if you do not deny access in your MySQL server settings).
The system, which is your MySQL installed under, has to be running! Then you can access it from multiple systems if allowed ;-)
I goggled a lot of time and found that running a Linux kernel is a solvable way and feasible solution.
Vagrant
It is a tool for building and managing virtual machine environments in a single workflow. The main reason why I argue you using vagrant is that it is not too heavy and does not swallow much of your computer resources. I believe you get through Vagrant documentation that will allow you to launch a Linux based machine on your physical machine.
Let's assume that the host machine is assigned IP 192.168.1.2 and the virtual machine has the IP address as 192.168.1.10, and make sure that the host and guest machine could see each other. Please read thoroughly Networking section to customise the network configuration.
Verifying connection between host and guest machine
Install MySQL Server
MySQL is a database management system. Basically, it will organise and provide access to databases where our site can store information.
Open a terminal in the machine has been set up from the above step. Run the following command:
sudo apt-get install mysql-server-5.6
Notes: It's up to the version of Linux distribution installed, the above command would be adjustable to suit your need. For install, I used the core of Ubuntu 14.04, see the link.
During the installation, your server will ask you to select and confirm a password for the MySQL root user. This is an administrative account in MySQL that has increased privileges.
Verifying the installation
From a terminal in the guest machine (i.e. the virtual machine), run the following command:
mysql -u root -p
will ask the MySQL password, then provide the one you have set up during MySQL Server installation. The following is the screenshot if you feed correct information to MySQL server.
Turn MySQL Server remotely accessible
Because we need a centralised database server where other computers could access and connect to the database of interest. Again, open a terminal and run the following MySQL commands:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'192.168.1.2' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH GRANT OPTION;
GRANT PROXY ON ''#'' TO 'root'#'192.168.1.2' WITH GRANT OPTION;
FLUSH PRIVILEGES;
which 192.168.1.2 is the IP address of the host machine and hashed string of password gets from user table in mysql database.
Okay. You might take a rest and enjoy your drink if there is no issue so far.
Verifying the remote access
From a terminal on the host machine, fire up the following command:
mysql -h192.168.1.2 -uroot -p
which is asking you to enter the password. If the root credential is correct, you would see a screenshot like the above one. One thing needs to be paid attention is to add -h192.168.1.2 following mysql command because we are not in the machine where MySQL server is installed.
All in all, we have set up a MySQL server used for both host and guest machine. In reality, if I have another machine assigned 192.168.1.3 can also connect to the database server and exchange data between server and client.

Connect to remote MySQL database with PHP using SSH

I have a remote database I'd like to connect to from PHP running locally. The database doesn't allow remote connections so ordinarily I SSH into the box and use it from the command line, but that's not really a long term solutions.
I have SSH access, I have MySQL access once I SSH in, but I don't know how to get PHP into that workflow. If I could make this work within MAMP, that would be great, too.
For developing or testing, you can use ssh command to setup tunnel first and then access the remote database as a local one. The steps are:
1) setup tunnel with ssh command. command format: ssh -L [local port]:127.0.0.1:[remote mysql port, by default, it is 3306] [user]#[remote mysql server ip]. sample:
ssh -L 3307:127.0.0.1:3306 ford#134.11.21.89
2) keep the command window alive
3) You can access the remote database by mysql string: mysqli://[user]:[password]#127.0.0.1:3307/[database name]
Connect to a MySQL server over SSH in PHP
You could set up a SSH tunnel and then point your php connection code to a local port which is forwarded through the tunnel. Under Windows you might use putty; for Mac there will be similar solutions.
If this is for development, the suggested solution by alex is the way to go; set up a ssh-tunnel.
The tunnel will redirect your 127.0.0.1:3306-requests to the remote machine. The remote machine will also belive the requests will come from 127.0.0.1 (locally).
However, you may encounter problems if your server (shared host? please specify) doesn't allow mysql-connections from 127.0.0.1 (quite commonly only localhost are allowed). There's a tiny difference in those, and it will inhibit your tunnel from reaching the remote mysqld.
Just google tunneling, set it up, and use 127.0.0.1 from your php-connection strings.
regards,
//t

Migrating drupal site from a Windows to a Linux machine

I had to migrate a drupal site from a Windows machine running the xampp package to a machine running Linux (Ubuntu 10.04).
I exported the database to a sql file on the source machine and recreated the database using the file on the destination machine. Also, i copied my website folder from the source to the destination. I also made the hostname,username and password changes in settings.php to reflect the mysql credentials on the destination machine,but when i try to access the site, i get the message 'Error connecting to mysql'.
What could be going wrong here ?
I would start over and install Drupal from scratch. You can leave all of your files alone, but get rid of sites/default/settings.php. Then run the /install.php script so that you know you're getting a proper DB connection. After you get back to square 1, then try bringing in your old DB. It's a PITA, but migrating Drupal sites tends to be.
The Backup and Migrate module can be really helpful in situations like yours. Try installing it on your dev site, run the backup, and then reinstall your staging site from scratch, install backup_migrate and then restore from there.
SSH to your web server and do
mysql -u username -h hostname -p
Can you connect using that? If that doesn't work, then it's something with your database server configuration. If that works, then it's something with your Drupal configuration.
What about
mysql -u username -h hostname -p databasename
If that works, try SHOW TABLES; to see if there's anything in there.
are you sure you go the right syntax
$db_url = 'mysqli://root:pass1#localhost/drupaldb'
and you have no prefix config.. i have moved many db and they all worked
.. are you sure you are using a standard port and there are no firewall issues
username:password#host:port/databasename

Categories