V4 MariaDB root access


#1

I’m just trialing v4 and one thing I’ve found is that I can’t see any documented access to the database.
I know there’s WP Cli, I know there’s PHPMyAdmin but sometimes I need raw MariaDB root access to install separate databases or even sometimes copy a DB for development. Where’s root password stored?


#2

Try checking /etc/mysql/conf.d/my.cnf


#3

That’s where it was for v3 but unfortunately no luck for v4. Mariadb seems to be installed only on its own docker but it surely has to have somewhere root password stored.


#4

@ralf


#5

Yes I’ve seen that but the subject is very specific. I need “root” access otherwise the setup is unusable for me. There’s heaps of information how to get or do changes to WP DB but what if there’s another DB needed for the project? Even simple CREATE DATABASE; command is not allowed for the user created by WP CLI.


#6

I found the mysql password here:

cat /opt/easyengine/services/docker-compose.yml | grep MYSQL_ROOT_PASSWORD

Added-That got me thinking about how to SSH connect my favorite macOS SQL tool Sequelpro. Setup SequalPro to connect via ssh to the remote server, then connect to the database via the ip address found below with root and password. Now you can remotely admin the MariaDB/MySQL from your mac.

docker inspect ee-global-db | grep IPAddress

#7

Try

docker exec -it ee-global-db bash -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD}'

#8

Added-That got me thinking about how to SSH connect my favorite macOS SQL tool Sequelpro. Setup SequalPro to connect via ssh then connect to the database via the ipaddress found below with root and password. Now you can remotely admin the MariaDB/MySQL from your mac.

That will work locally, but not on remote server. The IP you see is private and will not be accesible on public


#9

It does work from remote. The SSH connection creates a tunnel which gets me to the server, then the local address gets me into the database container.

Thanks for the docker exec -it hint. Now my backup script works from a cron job.


#10

Could you maybe let me know the steps you took to get this to work with SequelPro?

Edit: I got this to work reading back your other posts mram… thank you! I think it would be a good idea to start collecting some of these tips for other users. I’m making a list of some things I’ve found out so far…


#11

Ok, how do I setup remote db in version 4?


#12

Change the DB_HOST variable in the /opt/easyengine/sites/example.com/apps/wp-config.php

It kind of defeats the all-in-one nature of EE4, but if you are running a separate database or cluster that should get you going for now.


#13

You do it by passing --dbhost, --dbuser and --dbpass parameters while creating site - https://easyengine.io/commands/site/create/#ee-site-create-typewp


#14

Hi I have tried to create a site with remote parameters, but all I ever get is

sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
Configuring project.
Verifying connection to remote database
Warning: Unable to connect to remote db
Warning: Initiating clean-up.

I have made certain the database name, user, pw, and all mysql parameters match on the remote side. It just doesn’t work for some reason. I have followed old v3 guidelines as well.

I have confirmed that i can use mysql client as that user and create tables on the server side.


#15

I’ve tried this and on the remote mysql server, I’ve already created the user, db, and pw exactly the same, but all I get is database errors from wp. Do I need to dump the db from the already created locally wp db and import it into the remote?


#16

I let ee create the database and then just restore over the top of it. I have posted my working folder of ee scripts on github for everyone. The ee4-restore-site script is working for me using the ee shell command to restore the database from my v3 backups. I had a much harder time with the v4 backup once it was in a cron job and switched to a docker exec command.


#17

Thanks for these tools. I don’t have Amazon S3 for this project yet, How would I dump db for just one domain to /tmp in a one-liner? I’m just wanting to get one site running, and I’m not very familiar with docker yet. Thanks.


#18

Revised: Here is your 1 liner. Change the domain variable to your domain name. Dest is set to your home folder.

domain=example.com && dest=~/ && dbfilename=$domain-`/bin/date -u +"%Y%m%dT%H%M%SZ"`.sql && \
db_user=`ee site info $domain | grep 'DB User' | awk -F '|' '{print $3}' | awk '{print $1}'` && \
db_password=`ee site info $domain | grep 'DB Password' | awk -F '|' '{print $3}' | awk '{print $1}'` && \
db_host=`ee site info $domain | grep 'DB Host' | awk -F '|' '{print $3}' | awk '{print $1}'` && \
db_name=`ee site info $domain | grep 'DB Name' | awk -F '|' '{print $3}' | awk '{print $1}'` && \
docker exec ee-global-db bash -c "mysqldump --no-create-db --opt --add-drop-table -Q -h $db_host -u $db_user -p$db_password $db_name" > $dest/$dbfilename


#19

Super, thanks. I did something quick and dirty meantime.

sudo docker exec ee-global-db bash -c “mysqldump -h localhost -uUSER -pPASSWORD DBNAME” > /tmp/DUMP.sql

WIsh there was a bit more documentation of v4 ee!


#20

Now that I did all that and verified the db was restored properly, I still cannot connect remotely to mysql.

In wp-config, I changed global-db:3306 to the IPv4 of the remote mysql.

Is there something else I’m missing?