Connecting a Lightsail instance of WordPress to a Lightsail MySQL Database - mysql

This is my first go at AWS. I’m trying to install a WordPress site. Here’s what I’ve done so far:
Created a LAMP instance in Lightsail. I’m able to:
SSH into the webroot with Terminal
SFTP into the webroot with Filezilla
Successfully uploaded and expanded the latest version of WP
in the webroot
Using the public IP, accessed the WP setup screen
Created an instance of a MySQL database in Lightsail. I’m able to:
Use Terminal to tunnel into and access it in the browser with
PHPMyAdmin
Successfully create an empty database and user with full
access permissions
Additionally:
Both instances are running in the same region: Virginia, Zone A
(us-east-1a)
I have enabled both Data migration and Public Mode
At the WordPress setup screen I enter the database name, user, password and host. I believe the database host is what the instance calls the endpoint? After all that, I get the following error:
We were able to connect to the database server (which means your username
and password is okay) but not able to select the publicUser database.
I’m quite sure the required credentials are correct, so it must be something with how I’m doing the setup? Any ideas? If anyone has this same setup, can you please post your WordPress config file with the sensitive information removed so I can see how you're connecting?

You've done everything correctly so far. WordPress is now looking for a database with the name publicUser which it cannot find. You either did not create that database (via PHPMyAdmin) yet, or are using the wrong database name.
Once you have either created the database or corrected the configured database name, it should work.

Related

Get into the database Wordpress

I can not get into the database of my site. My hosting provider does not support database management. Enter the link domen.com/phpmyadmin but gives error 404. I found wp-config.php in which the registered username and password to the database.
How do I get into the database of my site? I need to make a backup.
In folder 'config' I have only 'defines.inc.php'
On the same server I have a website on prestashop in the database that I can go through phpmyadmin.
You could try to access remotely if it was configured this way, if you need a graphical interface you can use Mysql Workbench . If you can't access remotely and can upload php script try uploading adminer or installing phpMyAdmin yourself.

Restore .sql export to WordPress db from within WordPress?

I've been developing a client's site and have maintained .sql backups using Export of phpMyAdmin. Yesterday my client provided me with credentials for the destination server and asked if I could migrate the development site to the beta site.
I can copy the files, of course, and I have changed wp-config.php to point to the new database correctly. When I load the page initially a default WordPress installation is created.
Unfortunately, I was not provided cPanel or phpMyAdmin credentials.
Ideally, there would be a plugin or script that would drop all of the existing tables created by default and use my .sql export to recreate the tables and populate them with data.
Does anyone know if there is a way to import this .sql from within WordPress?
You can import it with mysql on the command line:
mysql -u someuser -p password <yoursqlfile.sql
Or you can open it in mysql workbench (download from mysql.com) and run it from there.
In case you cannot SSH to the server or access the database via workbench as Norbert suggested, you can try XCloner.
It would be better if you had some sort of direct access to the database, but I'm guessing if you do not have cpanel access you also do not have SSH access. It is also common for databases to be restricted to local access, so a remote connection via MySQL Workbench may not be an option.
If for whatever reason none of these solutions work, you can temporarily connect the site to a remote database that you have access to until you get the necessary credentials from the client.

old web host doesn't have phpmyadmin, remote access?

A new client of mine has a site hosted on netnation (boo). Their account manager doesn't have a way to access phpmyadmin or anyway to access the database. I'm not a programer, I'd just like to be able to view a stored password so I can give it to my client. I have the database host, user, password, and database name in the php files of the site.
Is there a program that I can use to view the database? No command line please it's not my thing and I'd probably break something.
Thanks
Most live databases don't allow direct access from outside the server, so if you're unlucky it can't work unless you can configure mysql to allow access from remote clients, too.
But at least you can try. Just configure any phpmyadmin installation (locally or on another server) to connect to that database. You do that in the file config.inc.php in the phpmyadmin root directory.
Look for the line that says "$cfg['Servers'][$i]['host'] = 'localhost';". Just replace 'localhost' with the url or IP your database is running (usually the same as the website). If your mysql allows remote access, you should be good to go. Otherwise you will have to re-configure your mysql installation first to allow that.
MySQL Workbench is a GUI program that allows access to MySQL database. It can work directly or using SSH. Most likely you won't be able to connect directly so your best chance is to get SSH access and connect using it. If it's not an option you can get FTP access and install phpMyAdmin (simply by uploading it to server).
Also, it's considered a bad practice to store password in DB, so it's very likely that the password itself is not stored, just its hash.

No "Privileges" in PHPMyAdmin, already tried deleting cookies/using FF/loggin in as 'root'

I'm well aware this has been asked lots of times before but none of the answers so far has been applicable for me or solved the problem.
I want to run SQL Queries from Python using MySQLdb
I get
OperationalError: (1130, "Host '77-172-143-12.ip.telfort.nl' is not
allowed to connect to this MySQL server")
This IP (77-172-143-12) is
for configuring my own router (at home)
I should create a new USER for this
but I don't have the privileges to CREATE USER...s
The Privileges tab is missing from PHPMyAdmin, also when I use Firefox and delete all cookies.
I can't log in
with root and a blank password: I got only one username/login from
my web hosting company when I registered my domain with them.
The
database is on a remote server which I don't manage myself and I seem
not to have any access to any MySQL config files.
How could this possibly be solved?
UPDATE
I understood from the answers that I can't solve this myself since my hosting provider doesn't allow it (by default anyway). I'll contact them to see whether they're willing and able to do something about it.
If somebody else has the same problem: as a workaround I'll keep using my Python routines on my local MySQL database. I'll then use the Wordpress export and import tools to transfer my (updated) local database to the remote server where my website is located. That's not too bad since it will also result in frequent backups of my articles.
It's normal that phpMyAdmin does not show you the Privileges (or Users in recent versions) tab, since you're not privileged.
Usually, on shared servers, hosting providers also use a shared MySQL server, thus they won't allow you root access.
They usually also allow MySQL access only from their web server and not from your home machine, as an additional security measure.
You need to add your hostname (see myip.nl) as a new host in DirectAdmin and then you can connect to the database on a remote server from a local application (Python in this case). See the screenshot below (sorry it's in Dutch!)

Installing phpmyadmin to be able to manage the mysql database the admin created for me

I dont have access to cPanel. I only can access the root of the site I am working on using FTP, with the domain name, user and password. I want to install phpmyadmin on the root so that I can manage the mysql database the admin created for me. I have the db name, user and password. What do I need to do? Do I need to download phpmyadmin, upload install it? Please give me some details and howto.
Will I actually be able to use it for such?
Also, how to migrate all contents of another mysql databse that I have also access to (having its: db name, user and password) to this one, that was created for the site I am working with.
Download phpmyadmin from the following site: http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.8.1/phpMyAdmin-3.5.8.1-all-languages.zip/download#!md5!a65d444787645735c75bca49cdb558cb
Upload it in a seperate folder on your webserver via FTP
Go to this folder and login with your database username and password
Correct the warnings and error on the bottom of the screen
(mostly security issues)
done :)
When you have any questions with errors or warnings please post a new question.