Comments (10)
Temporary fix:
open ~/.amp/services.yml
and remove the line db_type: mysql_dsn
Now do amp config
again
EDIT: there was a typo as pointed out below - fixed it
from amp.
The label on that option feels a little misleading to me, so I'll definitely change that part. A better label would be "Read username and password from ~/.my.cnf".
For context, most MySQL CLI tools (mysql
, mysqladmin
, mysqldump
, etc) already read user/password/host/port from ~/.my.cnf, so many admins have already created that file. This option tells amp
to read the same config file as all the other MySQL tools. You probably just need to create the file.
The option has been hidden for a long time, so it hasn't been tested across many configurations. It might not work in all environments/configurations. (In particular, it's common to hit snags on Windows/OSX, esp. if PHP+MySQL were packaged by different parties or if you rely on local sockets for PHP-MySQL communication.)
from amp.
Ah, your comment made me realize that I have not provided sufficient debug information.
System config
I am using Ubuntu 14.04
I have apache2 isntalled using the apt-get
resources and also have mariadb-server
installed for the sql server.
Also, I have the latest php5 in the official repos of Ubuntu 14.04 (All my packages are updated)
Things I tried to fix it
- I figured that the reason it failed was because the
~/.my.cnf
file didn't exist. I tried making an empty file - it still gave the error. - Then, I tried doing a systemwide search for
my.cnf
and found/etc/mysql/my.etc
was there. - I checked the contents and the info (port, host, etc) seemed correct.
- I linked the file using
ln -s
to~/.my.cnf
andamp
still gave that error. - I copied the content of the file into the
~/.my.cnf
and it still gave the error.
The surprising thing I found is that amp
gives the error even when I do amp config
to fix it or amp -h
. It seemed unusual - because I would have assumed -h
was handled before anything else
from amp.
- I'm not clear how
~/.amp/services.yml
would getdb_type: mysql_dns
. That might just be a typo, though (s/bmysql_dsn
). - To see why it crashes with invalid DB details, take a look at
app/defaults/services.yml
(specifically, see howinstances
depends ondb
) and look at5. Amp\Application->createCommands()
. You could potentially resolve that by changing the dataflow (i.e. instead of injecting theinstances
via__construct(...$instances)
, each command could do an on-demand lookup for$this->getContainer->get('instances')
. - FWIW,
/etc/mysql/my.cnf
and~/.my.cnf
usually look very different. To work withamp
, I usually make a~/.my.cnf
which looks like:
https://gist.github.com/totten/dd70747f06fa3ff24a7d
There's a pretty good chance your system's configuration is transporting data to mysql via local sockets and local user ID (rather than using TCP with username+password). Getting amp
to support local-sockets would be fiddly. The problem isn't so much the internal parts of amp
(although that's a definite consideration) -- it's the consumers (like civibuild
/Drupal/WordPress/CiviCRM) which obtain credentials using amp
. Ensuring that all of them work correctly is simpler if we support a single transport (ie TCP) rather than a mix of transports (TCP or sockets).
It would be nice to support local-sockets (since that's a common configuration on developer workstations), but I'm not sure it's worth the added complexity/QA/maint.
Perhaps we can reduce confusion by changing the label in amp config
:
[mysql_mycnf ] MySQL: Read user+password+host+port from $HOME/.my.cnf (experimental)
from amp.
@totten
About 1, sorry about the first point - it was a typo indeed. Edited my previous comment
About 3, AH ! I thought they'd be similar. My bad.
I agree changing the message would be helpful. Let me make a PR for that :)
from amp.
Cool. :)
If you want to get it out there, the other step would be:
- Go to https://test.civicrm.org/job/Tool-Publish-amp/ (in ~10 min). Find the latest build and check the console output. It should show the name of the latest
amp.phar
(e.g.amp.phar-XXXX-XX-XX-XXXX
) - Make a pull-request to change https://github.com/civicrm/civicrm-buildkit/blob/master/bin/civi-download-tools#L29
from amp.
@totten could you assign this to me so that I can keep track of things I'm working on ?
from amp.
@AbdealiJK, to assign the issue to you, we'll have to put you in an organization/team. I've setup the organization and invited you.
(Note: The URL of this project is changing from github.com/totten/amp
to github.com/amp-cli/amp
. The Github docs indicate that this should transfer well -- e.g. old forks and URLs on Github should adjust automatically. I haven't tried it before, but there are only a handful of forks, so this is about the best time to experiment with a transfer. I mention it in case there's some unforeseen consequence.)
from amp.
Accepted :)
Awesome - Closing this as the PR has been accepted and it has been fixed.
from amp.
Hello @AbdealiJK @totten I am currently having this issue while setting up CiviCRM vagrant build
For context I had to manually install a mysql-server using sudo apt install mysql server for the vagrant install to go through as Vagrant could not install it during vagrant up
vagrant@civi:~$ civibuild create d7-master
[[Download d7-master (type 'drupal-clean' in '/srv/www/d7-master')]]
Already downloaded d7-master
[[Install d7-master/default (type 'drupal-clean' in '/srv/www/d7-master')]]
[[Execute /home/vagrant/buildkit/app/config/drupal-clean/install.sh]]
++ source /home/vagrant/buildkit/app/config/drupal-clean/install.sh
+++ '[' -d /srv/www/d7-master/web ']'
+++ CMS_ROOT=/srv/www/d7-master/web
+++ amp_install
+++ _amp_install_cms
+++ echo '[[Setup MySQL and HTTP for CMS]]'
[[Setup MySQL and HTTP for CMS]]
+++ cvutil_assertvars _amp_install_cms CMS_ROOT SITE_NAME SITE_ID TMPDIR
+++ _cvutil_assertvars_back=ehxB
+++ set +x
++++ mktemp.php ampvar
+++ local amp_vars_file_path=/tmp/ampvar5Zd58c
+++ local amp_name=cmsdefault
+++ '[' default == default ']'
+++ amp_name=cms
+++ '[' -n http://d7-master.test ']'
+++ amp create -f --root=/srv/www/d7-master/web --name=cms --prefix=CMS_ --url=http://d7-master.test --output-file=/tmp/ampvar5Zd58c --perm=admin
PHP Fatal error: Uncaught RuntimeException: Failed to locate MySQL service via ~/.my.cnf in phar:///home/vagrant/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php:16
Stack trace:
#0 [internal function]: Amp\Database\MySQLCnfFactory::get()
#1 phar:///home/vagrant/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(951): call_user_func_array(Array, Array)
#2 phar:///home/vagrant/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(488): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), 'db.mysql_mycnf')
#3 phar:///home/vagrant/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(472): Symfony\Component\DependencyInjection\ContainerBuilder->get('db.mysql_mycnf')
#4 phar:///home/vagrant/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjectio in phar:///home/vagrant/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
Fatal error: Uncaught RuntimeException: Failed to locate MySQL service via ~/.my.cnf in phar:///home/vagrant/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
RuntimeException: Failed to locate MySQL service via ~/.my.cnf in phar:///home/vagrant/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
Call Stack:
0.0139 388408 1. {main}() /home/vagrant/buildkit/bin/amp:0
0.0358 587032 2. require('phar:///home/vagrant/buildkit/bin/amp/bin/amp') /home/vagrant/buildkit/bin/amp:10
0.0397 896696 3. Amp\Application::main() phar:///home/vagrant/buildkit/bin/amp/bin/amp:18
0.1051 3354184 4. Amp\Application->run() phar:///home/vagrant/buildkit/bin/amp/src/Amp/Application.php:59
Also I can Confirm that MySql is running
vagrant@civi:~$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Sat 2020-02-29 05:54:19 UTC; 6min ago
Process: 2682 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/my
Process: 2662 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit
Main PID: 2684 (mysqld)
Tasks: 28 (limit: 2209)
Memory: 172.0M
CGroup: /system.slice/mysql.service
└─2684 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Feb 29 05:54:18 civi systemd[1]: Starting MySQL Community Server...
Feb 29 05:54:19 civi systemd[1]: Started MySQL Community Server.
lines 1-13/13 (END)
also ~/.my.cnf exists
vagrant@civi:~$ cat ~/.my.cnf
# Custom MySQL configuration to save the root user's password for both client
# and mysqladmin access. This allows us to use `mysql -u root` to access
# MySQL rather than having to use a password.
[client]
user = root
password = root
host=127.0.0.1
port=3306
[mysqladmin]
user = root
password = root
Any Help will be appreciated thanks
from amp.
Related Issues (20)
- amp config - Better advice on httpd
- Connection must originate on localhost HOT 3
- Nginx support HOT 3
- Check for Apache mod_rewrite HOT 5
- NginX: Restrict access to sensitive directories
- Is app/defaults/services.yml distributed? HOT 1
- Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: Connection refused HOT 5
- nginx vhost view doesn't detect whether php is running on a port or a socket. HOT 3
- No random characters at the end of database name HOT 9
- amp config failed to read :7979 HOT 6
- Update README.md
- permissions: worldWritable not working for unprivileged users HOT 4
- Detect if we're running with encrypted home directories and suggest using AMPHOME instead HOT 3
- Allow longer database names HOT 5
- Make apache vhost config 12 factor friendly HOT 2
- Apache access denied without +x for user home directory
- Explicitly identify common stacks/environments
- Clarity / documentation
- Add ability to pass db user and password when creating (as we do with url etc) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amp.