virsh "Operation not supported: Cannot use direct socket mode if no URI is set" - qemu

Env: MacOS Arm64
Installed:
sudo port install virt-manager
Trying to create a default network following this
When I do this:
sudo virsh net-define --file default.xml
I get this:
error: failed to connect to the hypervisor
error: Operation not supported: Cannot use direct socket mode if no URI is set

I had the exact same problem while trying to run the FCOS on my Fedora laptop for the very first time.
Solution for Fedora-based system:
sudo dnf install libvirt
I would assume Ubuntu would accept:
sudo apt-get install libvirt
Regards!

I encountered this message and fixed it by adding uri_default = "qemu:///session" to /etc/libvirt/libvirt.conf
Of course the solution will be different if you're using a different hypervisor other than qemu.

Related

Problem with virsh / cannot connect to qemu

I am trying to setup KVM, but when running $ sudo virsh net-define br10.xml I get this:
error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
And when jumping into virt-manager GUI a get this dialog Unable to connect to libvirt qemu:///system.
I checked if I am in both kvm and libvirt groups and that seems okay.
I also checked if the libvrt-sock file is created when running $ sudo systemctl start libvirtd.service but there is nothing.
So it showed up that privilges for my files wasn't set correctly. Now everything works

How to install 'systemctl' on Ubuntu (docker)?

I have a docker with Ubuntu 16.04 and trying to install mysql-server in it.
Installation went fine (apt-get install -y mysql-server) and now is time to run a server:
systemctl status mysql
Failed to connect to bus: No such file or directory
How to find/install systemctl for Ubuntu 16.04 (docker) and are there alternatives?
Systemd is not installed on the ubuntu docker image. You can use the "service" command
service mysql start
service mysql status
You can also use the mysql docker image instead of installing mysql manually on ubuntu.
Ubuntu 16.04 is based on systemd, and systemctl tries to contact the daemon via d-bus. There are a number of solutions to solve this problem, one may be docker-systemctl-replacement.

mysql connect could not find driver [duplicate]

I have just installed Debian Lenny with Apache, MySQL, and PHP and I am receiving a PDOException could not find driver.
This is the specific line of code it is referring to:
$dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS)
DB_HOST, DB_NAME, DB_USER, and DB_PASS are constants that I have defined. It works fine on the production server (and on my previous Ubuntu Server setup).
Is this something to do with my PHP installation?
Searching the internet has not helped, all I get is experts-exchange and examples, but no solutions.
You need to have a module called pdo_mysql. Looking for following in phpinfo(),
pdo_mysql
PDO Driver for MySQL, client library version => 5.1.44
The dsn in your code reveals you are trying to connect with the mysql driver. Your error message indicates that this driver is unavailable.
Check that you have the mysql extension installed on your server.
In Ubuntu/Debian you check for the package with:
dpkg --get-selections | grep php | grep mysql
Install the php5-mysql package if you do not have it.
In Ubuntu/Debian you can use:
PHP5: sudo apt-get install php5-mysql
PHP7: sudo apt-get install php7.0-mysql
Lastly, to get it working, you will need to restart your web-server:
Apache: sudo /etc/init.d/apache2 restart
Nginx: sudo /etc/init.d/nginx restart
Update: newer versions should use php-sqlite3 package instead of php5-sqlite. So use this, if you are using a recent ubuntu version:
sudo apt-get install sqlite php-sqlite3
Original answer to question is here:
sudo apt-get install sqlite php5-sqlite
sudo /etc/init.d/apache2 restart
If your phpinfo() is not showing the pdo_sqlite line (in my case, on my Ubuntu Server), you just need to run the lines above and then you'll be good to go.
For newer versions of Ubuntu that have PHP 7.0 you can get the php-mysql package:
sudo apt-get install php-mysql
Then restart your server:
sudo service apache2 restart
I had the same issue. The solution depends on OS. In my case, i have debian, so to solve it:
Updated my php version from (php5 to php7)
Install php-mysql and php7.0-mysql
apt-get install php-mysql
apt-get install php7.0-mysql
I edited my php.ini locate at /etc/php/7.0/apache2/php.ini
uncomment the line : extension=php_pdo_mysql.dll
Then restart apache:
service apache2 restart
This solves my problem
On my Windows machine, I had to give the absolute path to the extension dir in my php.ini:
extension_dir = "c:\php5\ext"
Check if the module is available with php -m | grep pdo_mysql.
If not, for PHP 7.2, you can install relevant package with sudo apt install php7.2-mysql.
Use similar command on other PHP versions and package managers.
On Ubuntu just execute
sudo apt-get install php5-mysql
sudo apt-get install php-mysql
worked well on ubuntu and php 7
When adding these into your php.ini ensure the php_pdo.dll reference is first before the db drivers dlls otherwise this will also cause this error message too. Add them like this:
[PHP_PDO]
extension=php_pdo.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
for Windows 8.1/10 in :\\php.ini file you should uncomment line "extension=pdo_mysql"
Did you check your php.ini (check for the correct location with phpinfo()) if MySQL and the driver is installed correctly?
For PHP 5.5 on CentOS I fixed this by installing the php55-mysqlnd package.
sudo yum -y install php55w-mysqlnd # For Webtatic
sudo yum -y install php55u-mysqlnd # For Remi
For help installing, write a comment as it depends on the way PHP is installed on your system. Available repo's are webtatic and remi.
Check if extension_dir in php configuration file set correctly. Try to comment/uncomment some extensions and see if it's reflected on phpinfo().
If it doesn't then either php config file cannot be loaded (wrong location) extension_dir is commented or set to the wrong location.
In my case my DSN string was incorrect, specifically it did not contain mysql://. I would have expected a different error message, perhaps something like 'DSN string does not specify driver/protocol.'
Adding mysql:// to the beginning of the DSN string resolved the issue.
I had the same problem during running tests with separate php.ini. I had to add these lines to my own php.ini file:
[PHP]
extension = mysqlnd.so
extension = pdo.so
extension = pdo_mysql.so
Notice: Exactly in this order
I spent the last day trying to figure out why I was getting the following error. I am running Ubuntu 14.04.
The Problem:
I noticed that my PHP-CLI version was running php7.0 but php_info() (the web version) was displaying php 5.5.9. Even though php_info() said pdo was enabled, using the command line (CLI) wasn't recognizing the pdo_mysql command. It turns out that mysql was enabled for my old version but not the CLI version. All I did was install mysql for php7.0 and it was able to work.
This is what worked:
To check the version:
php -v
To install mysql for php7.0
sudo apt-get install php7.0-mysql
1) make sure your CLI version is the same as your web version
2) If they are different, make sure your CLI version has the mysql plug-in since it doesn't come with it as a default.
Incorrect installation of PHP was being called
I was experiencing the same problem. And I hope this would help someone who is having a similar issue as me.
Scenario
OS = Windows 10
Platform = XAMPP
PHP Version = 7 (Multiple Version seem to have been installed in the PC)
I created phpinfo.php file in the public folder and run the phpinfo() to look for the location of my php.ini file.
PHP.ini Location = c:\xampp\php\php.ini
Problem
Calling c:\xampp\htdocs> php -v returned PHP 7.2.3 but phpinfo.php showed PHP 7.2.2.
Solution
Instead of calling
php artisan migrate:install
which gave me this error, I used
c:\xampp\php\php artisan migrate:install
and it worked.
The problem is a missing php to mysql library. In CentOs i fixed it by running
# yum install php-mysql and then restarting apache with # /bin/systemctl restart httpd.service Note that the naming is slightly different from debian/ubuntu based distros, php->php5 and httpd->apache2.
I extremely recommend mysqllnd instead of mysql because of you would have a lot of problems like number converting and bit type evaluates problem with mysql extension.
on ubuntu install mysqllnd with following command:
sudo apt-get install php5-mysqlnd
In my case, I was using PDO with php-cli, and it worked fine.
Only when I tried to connect from apache, I got the "missing driver" issue, which I didn't quite understand.
A simple apt-get install php-mysql solved it. (Ubuntu 16.04 / PHP7. credits go to the selected answer & Ivan's comment)
Hope it can help.
PHP Fatal error: Uncaught PDOException: could not find driver
I struggled and struggled with "apt install php-mysql php7toInfinity and don't forget sqlite-what-ever's" and just could not get rid of this error message until I went back to basics and reset the file-permissions on the web-site in question.
These 3 commands reset file and folder permissions on the web-site and got it to work again.
cd /var/www/web-site-name.com/web/
# find (sub) directories and change permissions
find . -type d -exec chmod 755 {} \;
# find files and change permissions
find . -type f -exec chmod 664 '{}' \;
I Fixed this issue on my Debian 6.
Normally I just had installed php5-common package. After installation, you have to restart your web server (apache or nginx depending on which one you installed).
Then I just do an lsof on the apache process id (lsof -p process_id) as followed :
sudo lsof -p 1399 #replace 1399 by your apache process id
apache2 1399 root mem REG 254,2 80352 227236 /usr/lib/php5/20090626/xmlrpc.so
apache2 1399 root mem REG 254,2 166496 227235 /usr/lib/php5/20090626/suhosin.so
apache2 1399 root mem REG 254,2 31120 227233 /usr/lib/php5/20090626/pdo_mysql.so
apache2 1399 root mem REG 254,2 100776 227216 /usr/lib/php5/20090626/pdo.so
apache2 1399 root mem REG 254,2 135864 227232 /usr/lib/php5/20090626/mysqli.so
As you can see above, the modules are installed on a file path not known or guided by common library path: /usr/lib/php5/20090626/. For your installation, it may be different, but only the path of pdo_mysql.so, pdo.so, mysqli.so. So, this is why Drupal or any other php engine couldn't find the library and shows that error: PDOException: could not find driver
I just don't know why it is installed on such a weird path, for me it's just a bug in the library package installation script in debian 6.
I solved the issue by creating a symbolic for all the files under /usr/lib/php5/20090626/ to
/usr/lib/php5/ with this command :
ln -s /usr/lib/php5/20090626/* /usr/lib/php5/
$DB_TYPE = 'mysql'; //Type of database<br>
$DB_HOST = 'localhost'; //Host name<br>
$DB_USER = 'root'; //Host Username<br>
$DB_PASS = ''; //Host Password<br>
$DB_NAME = 'database_name'; //Database name<br><br>
$dbh = new PDO("$DB_TYPE:host=$DB_HOST; dbname=$DB_NAME;", $DB_USER, $DB_PASS); // PDO Connection
This worked for me.
I faced the same issue after I removed the php5 package (that includes all the drivers as well) in order to install php7 package. I actually installed php7 package without a mysql module.
I managed to solve it by typing in the terminal:
1) $ apt-cache search php7
which lists all the modules, looking through the modules I found,
php7.0-mysql - MySQL module for PHP
2) $ sudo apt-get install php7.0-mysql
That's it. It worked for me in my linux system.
(use the appropriate php version, yours could be php5)
Just one other thing to confirm as some people are copy/pasting example code from the Internet to get started. Make sure you have MySQL entered here:
... $dbh = new PDO ("mysql: ...
In some examples this shows
$dbh = new PDO ("dblib ...
For those using Symfony2/3 and wondering why you're getting this error. If you're using "mapping_types", you might encounter this error. The reason is that "mapping_types" is placed at the wrong level. For instance :
doctrine:
dbal:
mapping_types:
set: string
This "mapping_types" must be placed at this level :
doctrine:
dbal:
#To counter the error caused by 'mapping_types'
connections:
default:
server_version: %database_server_version%
mapping_types:
set: string
I hope this helps
I found the solution here : https://github.com/doctrine/DoctrineBundle/issues/327
Everywhere I go I read that the path of extension_dir should be changed from ext to an absolute path. It worked for me. However, when trying to build a server of my colleague's PC, I had to let the value to ext instead of putting an absolute path.
If you did put an absolute path and it does the extension is still not found, considerer trying both with the absolute path and ext.
Check correct path in extension_dir in you phpinfo().
Had the same issue, because I forgot to go into my virtual machine. If I go to my local directory like this:
cd /www/homestead/my_project
php artisan migrate
that error will appear. But it works on my virtual machine
cd ~/homestead
vagrant ssh
cd /www/homestead/my_project
php artisan migrate

Maria DB (mysql) installation on Red Hat . How do I start service after installation

I have installed mysql (maria db) on redhat.
My question is - how do I start and stop the server?
STEPS
I ran the command
$sudo yum install mysql
It gave long messages in the console while installing and and at the end said
Installed:
mariadb.x86_64 1:5.5.41-2.el7_0
Dependency Installed:
perl.x86_64 4:5.16.3-285.el7 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7
perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-2.el7
perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-285.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7
perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-3.el7
perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7
perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-285.el7 perl-macros.x86_64 4:5.16.3-285.el7 perl-parent.noarch 1:0.225-244.el7
perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7
But now when I run the command
$ sudo service mysql start
it gives messages
Redirecting to /bin/systemctl start mysql.service Failed to issue
method call: Unit mysql.service failed to load: No such file or
directory.
I am using Red hat version - Red Hat Enterprise Linux Server release 7.1 (Maipo)
I believe you've installed only the client. For the server do yum install mariadb-server. The package will install appropriate service file for you.
The name of the service though is mariadb. Well that is the case on CentOS 7 at least... So, after you install mariadb-server package do systemctl enable mariadb and systemctl start mariadb.
The service is called mysqld, not mysql. So:
$ service mysqld start
Or better yet, use the proper systemd syntax:
$ systemctl start mysqld

Connection time out installing mysql server in unix

I am trying to install mysql server in my AWS EC2 instance. I googled and executed the below command in the shell.
sudo yum install mysql-server
It throws the below connection timed out exception
Loaded plugins: priorities, update-motd, upgrade-helper
http://packages.us-west- 2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: [Errno 12] Timeout on http://packages.us-west-2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: (28, 'Connection timed out after 10001 milliseconds')
Trying other mirror.
Is this the right way to install mysql server?
Thanks.
installing mysql
From the current AWS EC2 documentation:
To install and start the LAMP web server
Connect to your instance.
To ensure that all of your software packages are up to date, perform a quick software update on your instance. This process may take a few minutes, but it is important to make sure you have the latest security updates and bug fixes.
Note
The -y option installs the updates without asking for confirmation. If you would like to examine the updates before installing, you can omit this option.
[ec2-user ~]$ sudo yum update -y
Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages. Use the yum groupinstall command to install multiple software packages and all related dependencies at the same time.
[ec2-user ~]$ sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
Note
Non-Amazon Linux instances may have subtle differences in their group names. If the above command fails because of an invalid group name, use the yum grouplist command and scan the output for similar groups, such as "MySQL Database server" instead of "MySQL Database", and use the appropriate group name for your distribution.
Install the php-mysql package.
[ec2-user ~]$ sudo yum install -y php-mysql
I suppose you only need to install mysql, so you just need to run the 1st command, adapt the second to only grab mysql from the repositories, and skip the last one:
[ec2-user ~]$ sudo yum update -y
[ec2-user ~]$ sudo yum groupinstall -y "MySQL Database"
Depending on which version of linux you have installed (Amazon, Red Hat or CentOS), you may need to change the string "MySQL Database" to something else. The following command:
[ec2-user ~]$ sudo yum grouplist
Will list all the possible group install you may perform, so you need to filter it to get the right string:
[ec2-user ~]$ sudo yum grouplist | grep -i mysql
And choose the most appropriate one in that filtered result set.
network connectivity
Now, regarding your specific issue, the FAQs describes your problem as follow:
If the AMI cannot access the yum repositories, it will timeout and retry multiple times before completing the boot procedure. Possible reasons for this are restrictive firewall settings or VPC settings, which prevent access to the Amazon Linux AMI package repositories.
If you encounter this issue you can either modify your environment so that the Amazon Linux AMI can connect to its package repositories [...]
Unfortunately, no explanations are given as yo how you can change your environment to enable connectivity.
Apparently, by using the dashboard, you should be able to open outbound access to the port the yum servers are using:
AWS dashboard > ec2 > security groups > default group > outbound rule: ??? (HTTP*) 0.0.0.0/???
The usual port for yum server is 80, so just replace ??? above by 80 to have access to the repos. You also should replace 0.0.0.0 with the actual repository server address.
If this solution does not work, you might also try disabling the firewall altogether for the duration of the update:
[ec2-user ~]$ sudo /etc/init.d/iptables stop
<...Update commands as listed above...>
[ec2-user ~]$ sudo /etc/init.d/iptables start
Or
[ec2-user ~]$ sudo /sbin/service iptables stop
<...>
[ec2-user ~]$ sudo /sbin/service iptables start
I just delete all the files in /etc/resolv.conf dir