mysqldump: Can't create/write to file error from amazon RDS - mysql

I am attempting to dump a database running on Amazon's RDS service, mysql version 5.5.27. Here's the command I'm running:
my-ec2-instance# mysqldump -hec2-xx-xx-xx-xx.compute-1.amazonaws.com -uuser -pwhatever mydb
I get the following error:
mysqldump: Couldn't execute 'show fields from `MyTable`': Can't create/write to file '/tmp/#sql_1405_0.MYI' (Errcode: 2) (1)
So, since the error message says its failing on "show fields", I tried to execute "Show fields from MyTable" from the mysql interpreter directly. I get what appears to be a file issue:
mysql> show fields from MyTable;
ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_1405_0.MYI' (Errcode: 2)
however, on the same EC2 instance that I am getting this error on, I can create this file and delete it:
my-ec2-instance# touch /tmp/#sql_1405_0.MYI; ls /tmp/#sql*;rm /tmp/#sql_1405_0.MYI
/tmp/#sql_1405_0.MYI
rm: remove regular empty file `/tmp/#sql_1405_0.MYI'?
I've tried the same thing from my local machine, and I get the same result. Googling this has not borne fruit. How can I prevent this error from occurring?

As Mike Brant suggested, I resized the instance on EC2, which forced it to switch machines, re-sized it back to the former size, and the problem no longer occurred.
I'm still not clear on the root cause, but it does appear to be down to some kind of bad state or misconfiguration specific to the EC2 instance I was using at the time.

Related

MYSQL no longer starting on Mac with MAMP

Up until today MYSQL was working OK for months with 2 MAMP Drupal localhost builds.
But now MYSQL no longer loads.
When opening MAMP the Apache Server starts,
whereas the MYSQL Server does not start.
This means the "Open WebStart page" option is greyed over and the Drupal path that would normally load the site just displays an error.
Using Terminal, if I run:
which mysql
the response is:
/Applications/MAMP/Library/bin/mysql
But if I try to login into MYSQL via Terminal:
mysql -u (myuser) -p
I am prompted for the password, but after entering correct password I receive:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/Applications/MAMP/tmp/mysql/mysql.sock' (2)
I checked that path, and there is no mysql.sock file there. In that directory there is just one file titled .dummy that has no content in it.
Some forums relating to the same error suggest I check and stop any other running MYSQL instances, but I don't appear to have any.
For example I ran:
ps -ef | grep mysql
And I just receive this:
501 11212 10699 0 12:31pm ttys000 0:00.00 grep mysql
I don't entirely understand that response, but it looks like there is nothing running that I can 'kill'.
Also, if I try things like:
sudo service mysql start
I am prompted for my Mac user password, which I enter, but I am then given the error:
sudo: service: command not found
Any help here would be greatly appreciated.
EDIT: I ran:
mysqld
And received a lot of information! Too long to paste here,
but some things I noticed were:
2019-02-14T03:01:33.211495Z 0 [Note] --secure-file-priv is set to NULL.
Operations related to importing and exporting data are disabled
I don't know how to address the above, but it sounds like it's not helping the situation?
Further on from there, the first 'warning' from the list was:
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
I followed that advice and ran:
mysql_upgrade
and received this error:
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
Any ideas as to how to fix that?
Some other errors I noticed are:
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
[ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
[ERROR] Aborting
followed by a lot of lines of "shutting down plugin...(various)..." that ended in:
mysqld: Shutdown complete
Again, I am completely lost here?
After hours of trying out suggestions from various forum threads, such as:
Creating my.cnf files; or
Adjusting the MAMP php.ini file with extra code, or
Reinstalling MAMP again,or
Dumping the "ib_logfile.." files from the MAMP/db/mysql57 directory,
The only thing that finally resolved this for me was:
I suddenly remembered I copied all my working files to a backup.
so I checked the backup directories for MAMP/db/mysql57 and noticed there was a lot of content in there that for some reason was now missing from my live version,
so I deleted everything in the current MAMP/db/mysql57 directory and pasted all the backup items in.
Suddenly MAMP's MYSQL server lights up, the Startup page auto loads into my browser and I can run drush commands in my CLI and load the Drupal CMS again.
Happy Days!

MySQL can show tables but cannot access data (errno: 13 - Permission denied)

I am fixing a server that uses Bitnami to run a WordPress site. I did not set up the server – it ran out of memory and crashed.
I was able to restart MySQL through the bitnami ctlscript, and I am able to access the MySQL CLI, but I cannot execute any queries that return data INSIDE the tables.
The following commands all work, and generate the expected output:
show databases;
use database 'x';
show tables;
As soon as I try to view table data (SELECT * FROM ...), this error shows up:
2019-01-15T18:25:19.507808Z 233 [ERROR] /opt/bitnami/mysql/bin/mysqld.bin: Can't find file: './bitnami_wordpress/wp_options.frm' (errno: 13 - Permission denied)
What I've tried:
Database file permissions. All data (specifically the
wp_tablename.frm files) is chowned by mysql:mysql
I confirmed this by changing permissions to my server user, restarting and trying to access mysql again, but the commands above, which already worked, broke, so I changed it back.
Reboots of all sorts. Bitnami, server, etc.
Selinux. I am 95% sure it is not running on this server (all commands
that check its status / install info return 'use apt-get to
install this package) or something like that.
Please help! This site is in production!

mysqldump: Got error: 1: "Can't create/write to file '*.txt' (Errcode: 13 "Permission denied")" when executing 'SELECT INTO OUTFILE'

Linux. No SELinux (disabled).
I try to run this command as my linuxuser (member of group mysql):
mysqldump --user=root --tab "/some/folder" dbname
Getting this error:
mysqldump: Got error: 1: "Can't create/write to file 'sometable.txt' (Errcode: 13 "Permission denied")" when executing 'SELECT INTO OUTFILE'
If I look in the folder, there is a sometable.sql file, but no txt file.
As I understand, the sql file is created from the user's name who run the command (linuxuser in my case), but the txt file gets generated by mysql server (mysql user in this case). Note that mysql user is also a member of mysql group.
What could be the problem? Tried everything :)
If you trying to execute a mysqldump in a client diferent that the server
can be a problem
I tried with mysqldump Ver 10.14 Distrib 5.5.56-MariaDB, for Linux (x86_64), and works only with the /tmp/ dir.
Perhaps, help info say that will not work
-T, --tab=name Create tab-separated textfile for each table to given path. (Create .sql and .txt files.) NOTE: This only works if mysqldump is run on the same machine as the mysqld server.
The solution was to change "some/folder" to an external location. Looks like there were permission problems because originally the folder mentioned was under Perforce root and probably it had read-only permissions.
I then changed the new folder permissions to:
mylinuxuser:mysql
making sure that both the user with which the process was started, as well as mysql server have permissions to write there. This is because the sql file is written from user's name and txt file is written from mysql server's name.
I also added my user to the mysql group.
This was something I just found and wanted to pass along for the folks searching for the same answer.
This has been occurring on systems running systemd. In the /lib/systemd/system/mariadb.service file is the setting, 'PrivateTmp=true'. This is a security measure to prevent the data from being seen by folks who shouldn't be seeing it.
If you run:
SELECT * TO OUTFILE '/var/tmp/tablename.txt' FROM TABLENAME;
It will create the file but it creates it in a systemd protected directory.
/var/tmp/systemd-private-[hash]-mariadb-[hash]/tmp/tablename.txt
You can either save the data from here which is perfectly acceptable or stop mariadb, create the directory /etc/systemd/system/mariadb.service.d and in that directory create the file 'mariadb.conf' (as an example; any file should do) with the following:
[Service]
PrivateTmp=false
Run systemctl daemon-reload to reload the configuration and restart mariadb.
You should be able to create backups now.
What has worked for me (in Windows), trying to export a file using:
SELECT * INTO OUTFILE 'C:/documents/dumps' from file
MySQL Service properties --> Log on: take note account defined.
Directory C:\documents\dumps --> properties --> Security: account defined above needs read/write privileges

MySQL Workbench not allowing for me to drop a database

This is quite odd, it's happening only for a some Databases, but I get this error:
ERROR 1010: Error dropping database (can't rmdir './main', errno: 66)
SQL Statement:
drop database `Main`
This happens over and over, even on Root user...
This happens even if there is nothing in the database.
mysql> drop database DB_NAME;
ERROR 1010 (HY000): Error dropping database
(can't rmdir './DB_NAME', errno: 66)
1) mysql -e "select ##datadir" -> /usr/local/mysql/bin/mysql
2) Go to DB folder: cd /usr/local/mysql/data/
3) Delete DB folder of DB with issue (in this case: "DB_NAME")
Source stack overflow
I figured out, and it wasn't all that hard, using the OS X terminal I entered this in:
open /usr/local/mysql/data/
then, I just deleted the folders. An admin password was required though.
Thanks to anyone that offered to help

MySQL Server has Gone Away in Drupal 7

In my form field type, i edit the file menu these error will appear,
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in
D:\wamp\www\cms_development\includes\database\database.inc on line
2168 ( ! ) PDOException: SQLSTATE[HY000]: General error: 2006 MySQL
server has gone away in
D:\wamp\www\cms_development\includes\database\database.inc on line
2168
Anybody Know how to rectify this error...
This may be because of max_allowed_packet
Change in the my.ini/my.cnf file. Include the single line under [mysqld] in your file
max_allowed_packet=500M
now restart the MySQL service once you are done. You can see it's curent value in mysql like this:
SHOW VARIABLES LIKE 'max_allowed_packet'
You can read about it here http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html
This is for Linux Users.In terminal,
Step 1:
locate my.cnf
And you copy the Path
Step 2:
sudo gedit "Paste the path"
Step 4:
Changed "max_allowed_packet" from "1m" to "32m" and saved my.cnf
sudo "path" restart
(or) Do Normal System Restart
I had a similar problem. mysql would crash while drupal8 was going through install process. restarting mysql would eliminate the "mysql has gone away ..." error but drupal install would never finish. the following combination of mysql and apache configs provided a stable digitalocean droplet for me:
https://www.digitalocean.com/community/questions/mysql-server-keeps-stopping-unexpectedly?answer=26016