Questions about Vagrant

3

I'm learning to work with the , I've already created VirtualMachine , I made the provisioning, the project ran perfectly.

But when I enter via in VirtualMachine to run a script , which runs via shell, is experiencing a connection error with the .

  

"cdbconnection failed to open the db connection: could not find driver"

I use the framework . Another thing is when I run the vagrant reload I lose access to the web server remotely.

    
asked by anonymous 12.02.2014 / 12:36

2 answers

3

The error message is clear: the MySQL database access driver could not be found.

The extension was probably not enabled. Check out your php.ini . On Windows, something like:

extension_dir="C:/php5/ext/"
extension=php_mysql.dll

On other systems, something like:

extension_dir="/usr/lib/php/modules/"
extension=mysql.so

A Windows user said that Yii requires extension=php_pdo_mysql.dll (that is, " php_pdo_mysql " instead of " php_mysql ").

It is also important to remember restart PHP and / or Apache after making changes to the configuration files.

Sources:

12.02.2014 / 17:07
1

Your DSN shows that you are trying to use the MySQL driver and the error indicates that the driver is unavailable.

Verify that the extension is installed.

In Ubuntu / Debian you can do the following to verify that it is installed

dpkg --get-selections | grep php5-mysql

If it is not, you can install it as well

sudo apt-get install php5-mysql

Then restart apache for the new settings to take effect.

sudo /etc/init.d/apache2 restart

If already installed check which host MySQL is accepting connections to. Run

sudo nano /etc/mysql/my.cnf

Change bind-address to 0.0.0.0 to listen for connections from any IP.

bind-address = 0.0.0.0

Give connection permission for all IPs

mysql -u root -p

At the MySQL prompt type

use mysql
// Caso o root não possua senha use
GRANT ALL PRIVILEGES ON *.* TO [email protected]'%'
// Se tiver senha use
GRANT ALL ON *.* to [email protected]'%' IDENTIFIED BY 'senha';
FLUSH PRIVILEGES;
exit

Restart MySQL

sudo /etc/init.d/mysql restart
    
12.02.2014 / 13:42