ERROR 1290 (HY000): The MySQL server is running with the –secure-file-priv option so it cannot execute this statement

Problem

You want to export a MySQL database table as a csv with something like:

mysql> select * from table_name into outfile '/tmp/table_name.csv';

but you get the error that MySQL cannot execute this command.

Solution

Find out the location that MySQL can use to export files by running the following:

mysql> show variables like 'secure_file_priv';
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.00 sec)

and then use the path to change the outfile path (ie /var/lib/mysql-files/table_name.csv).

Taken from the answer here

To enable extensions, verify that they are enabled in those .ini files:

Problem

You are trying to install the dependencies in a PHP Symfony project, but you get an error about enable extensions in ini files.

Solution

Make sure that you install the correct packages for the PHP version you are using. So installing php-curl while using PHP 7.1 results in the error.
When installing php7.1-curl the installation completes successfuly.

Docker Cloud moving one node from one account to another

Problem

You have used ‘Bring your own node’ to use a server with one account, but you want to change the account and move the node to the new one.

Solution

Use your old account to terminate the node or login to the server and use the following to stop the running dockercloud-agent:

sudo service dockercloud-agent stop

Go to the Docker Cloud web ui interface, and use the 'Bring your own node'. Copy the token that appears after the sudo -H sh -s on the popup window.

On the server update the token with the one from the new account that you just copied, by running the following:

sudo dockercloud-agent set Token=xxxxx_new_token_xxxx

And now restart the dockercloud-agent on the server:

sudo dockercloud-agent restart

You should now be able to see 'Node xxxx detected' on the Docker Cloud web ui after a couple of minutes.

Copy file from host to vagrant

Problem

You would like to quickly copy a file from the local host to the vagrant machine.

Solution

Find the private key, ssh and IP port with ssh-config:

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /path/to/private/key
  IdentitiesOnly yes
  LogLevel FATAL

Copy the file using the private key as a parameter to scp:

scp -P 2222 -i /path/to/private/key /path/to/file vagrant@127.0.0.1:~

Taken from the answer here

Create a MySQL table with dashes

Problem

You want to create a MySQL table that contains spaces, but when you try you get the following error message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-afterdash' at line 1

Solution

Use the backticks to create the table:

mysql> create database `table-afterdash`;
Query OK, 1 row affected (0.00 sec)

Bash getting the parent folder name from a bash defined variable

Problem

You have defined a variable in a bash script (ie MY_FOLDER) but you also want to dynamically get the parent folder (ie MY_FOLDER can have multiple values).

Solution

Use the dirname as in the following

MY_FOLDER=/home/user/first_folder/second_folder
MY_PARENT_FOLDER=$(dirname $MY_FOLDER)

echo $MY_FOLDER
echo $MY_PARENT_FOLDER

.......
/home/user/first_folder/second_folder
/home/user/first_folder

Removing a range of history lines from bash history

Problem

You would like to remove some lines from the bash history (ie using cut and paste with wrong values).

Solution

You can use the following, taken from the answer here

for i in {1..no_of_lines}; do history -d start_line; done

where start_line is the start of the lines you want to remove and no_of_lines is the number of lines you want to be removed.