Db dump in trellis development stage

Hi eveyone
It is possible to restore a sql dump in trellis development?

I tried but it messed up

You could either:

  1. Connect via a programme such as Sequel Pro and follow the docs for for set up instructions: https://roots.io/trellis/docs/database-access
  2. Use WP CLI to import

Thanks Nath I’ll try

@nathobson following your advice I installed webmin (I use linux); when I log in the mysql manager I can see all the db structure but If i try to modify smt I get this error message:

Blockquote DBI connect failed : Access denied for user ‘example_com’@‘localhost’ to database ‘mysql’

So I tried to log in the db through ssh and I am able to login in the db but when I try to create a new db or add a new user I get this error:

Blockquote ERROR 1044 (42000): Access denied for user ‘example_com’@‘localhost’ to database ‘newdb’

My question is: there a root user and password for this db?

or there is a different way to proceed

I accept any suggestion

You should find the credentials in your development vault.yml.

I am using that credential but I am experiencing problems like said before
Access denied

You will find in group_vars/development/vault.yml that you have two MySQL passwords. One is for your WordPress installation and is db_password. The other is for the root MySQL account and you can find it at the top of the file under vault_mysql_root_password.

Which credential are you trying to use?

1 Like

I am using user example_com and password the one in db_password.

The problem isn’t access the db because it works the problem is when I try to add a db or a user
and then I get access denied

MariaDB [(none)]> CREATE DATABASE db1;
ERROR 1044 (42000): Access denied for user 'example_com'@'localhost' to database 'db1'

The user example_com only has access to one database. If you want to add other users or databases you must use the root account and root password.

1 Like

perfect, how I get root access? what password I’ve to use?

You login with user name root and whatever your vault_mysql_root_password is, which should be in your vault.yml.

1 Like

Solved: following the @danielroe suggestion I recovered the root password in the db and now I’ve full access.

For anyone who has the same problem here there is the complete procedure used:

  • After Vagrant ssh, sudo su to have root privileges, stop the database service and check the service status
systemctl stop mariadb
  • Start the service with –skip-grant-tables
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mariadb
systemctl status mariadb

You must have something like this:

 CGroup: /system.slice/mariadb.service
        └─4773 /usr/sbin/mysqld --skip-grant-tables
  • Now Login in the db as root without password
mysql -u root
  • Change the root password
MariaDB [(none)]> USE mysql;
MariaDB [(none)]> UPDATE user SET password=PASSWORD('YourNewPasswordHere') WHERE User='root' AND Host = 'localhost';
  • Restart Mariadb normally
systemctl stop mariadb
systemctl unset-environment MYSQLD_OPTS
systemctl start mariadb

That’s all.