aaemnnosttv / wp-cli-valet-command

Harness the power of Laravel Valet for creating fully functional WordPress installs in seconds.
https://aaemnnost.tv/wp-cli-commands/valet/
299 stars 31 forks source link

Ubuntu 20.04 database errors #69

Closed sabelapaulo closed 3 years ago

sabelapaulo commented 4 years ago

wp valet new site --dbpass=local_root_password doesn't seem to work for me on Ubuntu 20.04.

I get the output:

Don't go anywhere, this should only take a second...
Error: ERROR 1698 (28000): Access denied for user 'root'@'localhost'

mysql is installed, but mysql -vgives me:

% mysql -v
ERROR 1045 (28000): Access denied for user 'foobar'@'localhost' (using password: NO)

I then also installed sqlite3, and created a ~/.wp-cli/config with the following:

valet new:
  ## Uncomment or update the relevant lines when necessary to set your own defaults.
  project: wp # or bedrock
  # in: # override - defaults to current directory
  version: latest
  # locale:  # use if not English
  db: sqlite
  # dbname: # defaults to wp_name
  # dbuser: root # or any other local user capable of creating databases (MySQL only)
  # dbpass: # enter the appropriate password if necessary (MySQL only)
  dbprefix: wp_
  admin_user: admin
  admin_password: admin
  ## Boolean options can also be configured, too.
  # unsecure: false # set to true to override
  # portable: false # set to true to override

But it doesn't seem to be using sqlite? I'm not sure. I don't care which database is used, just whichever one is the simplest to configure. Any advice?

aaemnnosttv commented 4 years ago

Hi there! Regarding the mysql error, you may find this answer useful.

As for your attempt to use sqlite, did you run the new command again after creating that config file? You mentioned creating a ~/.wp-cli/config but it should be ~/.wp-cli/config.yml. You can check the loaded config files by running wp --info.

The updates to the config file are not really necessary unless you want to change the defaults. If you just want to create a new site using sqlite, you can run wp valet new site --portable and you should be good to go.

Let me know how it goes 😄

sabelapaulo commented 4 years ago

Thanks much for the response, and how embarrassing I forgot the .yml in config.yml! I tried updating the ~/.wp-cli/config.yml and then testing the commands again and unfortunately it still didn't work for me. I get the same error messages. I can't be certain that it is attempting to use sqlite vs mysql though. The packages I've installed are libsqlite3 and sqlite3.

I tried wp valet new site and wp valet new site --portable, but neither seem to work. I get the same mysql error without the --portable and with --portable I get this error message:

% wp valet new site --portable
Don't go anywhere, this should only take a second...
Error: ERROR 1698 (28000): Access denied for user 'root'@'localhost'

I did then try to implement SO answer you mentioned (option #2). I can now mysql -v without any error unlike before, but still get the same error doing wp valet new site or wp valet new site --portable.

aaemnnosttv commented 4 years ago

Hmm, that's definitely a mysql error when it shouldn't be trying to use mysql.

Can you please show me the specific version of the command you're running? You can see it with this command:

composer show aaemnnosttv/wp-cli-valet-command -d ~/.wp-cli/packages

You can share the whole thing there, but the values of source and dist are the relevant parts of it.

dirad commented 3 years ago

^^

Im getting this same error... on Ubuntu 20.04 , Trying with a bedrock project, new mariadb installed via apt.

these are from composer show

source   : [git] https://github.com/aaemnnosttv/wp-cli-valet-command.git 739ed285192d04086d2453c00ed7d9260fd609fa
dist     : [zip] https://api.github.com/repos/aaemnnosttv/wp-cli-valet-command/zipball/739ed285192d04086d2453c00ed7d9260fd609fa 739ed285192d04086d2453c00ed7d9260fd609fa
aaemnnosttv commented 3 years ago

After testing this on Ubuntu 20 I found that there are a few extra steps needed after installing mysql-server to allow running commands as the mysql root user.

First, login to mysql as the root user (requires sudo at first which is why this is failing)

$ sudo mysql -u root

Then from mysql prompt (Source):

mysql> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin IN ('unix_socket', 'auth_socket');
mysql> FLUSH PRIVILEGES;
mysql> exit

Finally, restart the mysql service

$ sudo service mysql restart

The valet command then works as expected 👍

vagrant@ubuntu-focal:~/sites$ wp valet new site --unsecure
Don't go anywhere, this should only take a second...
Success: site ready! http://site.test