Connection to mysql

Hi,
I need to connect mysql:
I did
vagrant ssh
then:
vagrant@ascension:~$ mysql -u ascension.dev -p
and the password in vault: xy&G6o2kKH$#AFz247N.

developement/vault.yml:

# Documentation: https://roots.io/trellis/docs/vault/
vault_mysql_root_password: "xy&G6o2kKH$#AFz247N."

# Variables to accompany `group_vars/development/wordpress_sites.yml`
# Note: the site name (`example.com`) must match up with the site name in the   above file.
vault_wordpress_sites:
  roots.ascension.com:
    admin_password: "DM93zj,o29KjT/bh$8G$"
    env:
      db_password: "qP42q2*?hjt.P+x7Bzc6"

developement/wordpress_site.yml:

wordpress_sites:
  roots.ascension.com:
    site_hosts:
      - canonical: ascension.dev
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    admin_email: xavierartot@gmail.com
    multisite:
      enabled: false
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false

I tried the password in

cat site/.env

DB_HOST='localhost'
DB_NAME='roots_ascension_com_development'
DB_PASSWORD='qP42q2*?hjt.P+x7Bzc6'
DB_USER='roots_ascension_com'
DISABLE_WP_CRON='True'
WP_ENV='development'
WP_HOME='http://ascension.dev'
WP_SITEURL='http://ascension.dev/wp'

Have you checked out the Trellis docs: Database Access | Trellis Docs | Roots?

Specifically:

Connection type: SSH
MySQL host: 127.0.0.1
Username: example_com
Password: example_dbpassword (use the value of db_password from group_vars/development/vault.yml)
SSH Host: example.dev
SSH User: vagrant
SSH Key: Select the following file from your Trellis directory: .vagrant/machines/default/virtualbox/private_key

I did, but if I don’t have access from vagrant with a tools like Sequel Pro it doesn’t going to work

I meant more about the connection info. For example, you can connect in the way you wished by changing:

vagrant@ascension:~$ mysql -u ascension.dev -p

to

vagrant@ascension:~$ mysql -u ascension_dev -p

Note that the . is replace with an _.

Then, for the password, you use the value of db_password within group_vars/development/vault.yml.

I have this error:

mysql -u ascension_dev -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Then mysql isn’t running? Is your site working? You can always try to run sudo service mysql start.

In the future, I’d use wp db cli from /srv/www/project_name dir. It automatically uses the WP credentials so you don’t have to manually do it.

1 Like
mysql --version
mysql  Ver 15.1 Distrib 10.0.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
vagrant@ascension:~$ mysql -u ascension_dev -p
Enter password:
ERROR 1045 (28000): Access denied for user 'ascension_dev'@'localhost' (using password: YES)
vagrant@ascension:~$