MySQL Errcode 2 - problems creating database directories - mysql

This doesn't seem far too specific, but somehow I cannot find anyone else with this problem (at least on stack and google). People have issues with errcode 2, but every thing I've seen is people having issues with mysql's tmp directory. I've tried changing that, and that's given no luck.
I've also made sure that the owner/group of the mysql "datadir" is mysql.
I'm assuming the cause of this is because I have recently moved the mysql datadir to my /ssd directory.
I have changed the datadir location after copying /var/lib/mysql to /ssd and have restarted mysql.
For /var/lib/mysql, I renamed the mysql folder to mysql-old, as that folder was no longer in use. Just in case, I created a symlink in place of it that points to the /ssd/mysql directory.
For context, I am trying to import an sql file and it seems it cannot create the data or directories themselves. Here is the full error:
ERROR 1 (HY000) at line 33: Can't create/write to file '/var/lib/mysql/changelog/changelog.MYI' (Errcode: 2)
In this instance, I'm trying to import a database named changelog
Even after changing the datadir entirely, it still seems to want to write to /var/lib/mysql - Why is that?

You may try to look into section [mysqld] in my.cnf or mysqld.cnf in /etc/mysql/
It could be either due to too many files being open or tmp directory having no permission for your user.
http://alvinalexander.com/mysql/mysql-cant-create-write-file-error-message

I ran into similar error message when trying to create a new database. The final solution is uninstall mysql and reinstall it again. Everything was fine. There are some corruption in the file which caused the errno 2.

Related

Unable to Start MySql (8.0.15) on OS-X High Sierra (10.13.6) PID File

Starting on PHP/MySQL Development and as the title states, downloaded MySQL 8.0.15 DMG. Installed. However, when I attempt to run the terminal command:
"sudo /usr/local/mysql/support-files/mysql.server.start"
I get:
"Starting MysQl .......... "
which finally ends in:
ERROR! The server quit without updating PID file (/usr/local/mysql/data/Macbook.hsd.comcast.net.pid)
So far I have tried:
Tried to remove the "Macbook.hsd.comcast.net.pid" file located in the data directory but all i keep getting a "No Such file or directory"
To look for default "my.cnf" file to mod or to add the default values, HOWEVER I read that: "By default the OS X installation does not use a my.cnf, and My SQL just uses the default values. To set up your own my.cnf, you could just create a file straight in /etc.
An "auto.cnf" exists in the data folder, i'm not sure if MySQL uses that or would respect a "my.cnf" created in the /usr/local/sql/data/ folder.
I'm not sure of the proper location to create a "my.cnf" (see, all I want to do is set the proper value for the "pid-file" such as pid-file = /var/run/mysqld/mysqld.pid and then create the directory and give it the proper permissions. SEE UPDATE AT BOTTOM:
I'm cannot access the "data" folder in MySQL folder (which is alias of): "/usr/local/mysql-8.0.15-macos10.14-x86_64/". It keeps telling me I don't have permission. There is a little red dot
I have set checked the permissions in "/user/local/mysql/" and did a
"sudo chown -RL root:mysql /user/local/mysql"
"sudo chown -RL _mysql:mysql /usr/local/mysql/data"
In the /mysql/ directory now everything reads:
Stumped and not sure where to move on from here.
Is the fact that I can't access the data folder a result because I haven't made one/specified one? Can't seem to find an answer for getting MySQL working with HighSierra/Mojave. I can't believe that it's just dead.
I would appreciate any/all help.
UPDATE/EDIT:
Was able to add my user permissions to the "/user/local/mysql/data" folder and was finally able to access the error file ("Macbook.hsd.comcast.net.err") and a "auto.cnf".
The "auto.cnf" file is empty besides a single line: [auto] server-uuid=e7986494-331d-11e9-9691-bec9b3249da6 (not sure if I need to modify the auto.cnf and add PID entries). See error BELOW which seems to indicate otherwise.
The Error file had repeated Errors (occurred several Times):

Xampp-mysql - "Table doesn't exist in engine" #1932

Xampp error after moving xampp folder:
Apache is running fine:
as given below image i'm sucess to run apache but unable to run mysql if in case i moved and run xampp both apache and mysql but its shows error which is fresh and it show the error like "Table doesn't exist in engine" #1932 as given up image. please solve the issue anyone help pls
I have faced same issue and sorted using below step.
Go to MySQL config file (my file at C:\xampp\mysql\bin\my.ini)
Check for the line innodb_data_file_path = ibdata1:10M:autoextend
Next check the ibdata1 file exist under C:/xampp/mysql/data/
If file does not exist copy the ibdata1 file from location C:\xampp\mysql\backup\ibdata1
hope it helps to someone.
Copy the ib_logfileXX and ibdata
file from old mysql/data folder to the new mysql data folder and it will fix the issue
If you have copied & Pasted files from an old backup folder to new then its simple.
Just copy the old ibdata1 into your new one. You can find it from \xampp\mysql\data
And restart your mysql.
Don't copy ibdata1 file
This occurred to me when I take all files from the backups folder. There is a file you should not copy with other folders and files, called ibdata1.
stop mysql
copy xampp\mysql\data\ib* from old server to new server
start mysql
I have faced same issue but copying the xampp\mysql\data\ibdata1 was not solved my problem, because I install new version of xampp, if you upgrading your xampp first make backup from all htdocs and mysql folder, in my case I just backup the all xampp to the new folder like old-xampp then install new xampp and then you need do the following steps before starting your new xampp servers:
Backup the phpmyadmin folder and ibdata1 from your new installation form this location xampp\mysql\data.
Then Go to your old xampp folder old-xampp\mysql\data and copy the ibdata1 file and phpmyadmin from old location.
Then open your new xampp folder xampp\mysql\data and past them there.
Start the xampp servers.
You could:
Rename data folder to data-old
Create new folder and set name to data
Copy backup folder in data folder
Copy ibdata1 in data-old to data folder
Restart MySQL and Apache
After solving the problems, get output power from the database
I had previously moved my mysql directory and forgot to change ALL references to the old location in \mysql\bin\my.ini.
change these three lines:
datadir = "/programs/xampp/mysql/data"
innodb_data_home_dir = "/programs/xampp/mysql/data"
innodb_log_group_home_dir = "/programs/xampp/mysql/data"
Change "/programs/xampp/mysql/data" to new location
this one was commented but I changed it anyways
#innodb_log_arch_dir = "/programs/xampp/mysql/data"
ok step one you can copy from your old xampp xampp\mysql\data\ibdata1 and step two paste to your xampp new xampp\mysql\data\ibdata1 ,
and than open your xampp controller and stop mysql and start again.
i tried this and is work for me
100% working solution
Stop MySQL and Apache and quit Xampp.
Make a backup of the "data" folder.
C:\xampp\mysql\data
Copy all the files from this folder
C:\xampp\mysql\backup
4. Paste and replace to
C:\xampp\mysql\data
Instructions for Ubuntu users:
Copy a database (e.g. from the external disk backup).
sudo cp -r /media/some_user/mysql/some_database/ /opt/lampp/var/mysql/
NOTE: from this moment on, the database already appears in PHPMyAdmin, but if you click on it, the tables still do not appear
Change the owner to mysql (because when copying the owner it was changed to root)
sudo chown -R mysql:mysql some_database/
NOTE: from this moment the name of the tables appears but you can't see their structure or data - it shows the error "#1932 - Table 'some_database.some_table' doesn't exist in engine"
Copy the ibdata1 file and also change the owner.
sudo mv ibdata1 ibdata1_old
sudo cp /media/some_user/mysql/ibdata1 /opt/lampp/var/mysql/
sudo chown -R mysql:mysql ibdata1
Restart XAMPP
sudo /opt/lampp/lampp restart
Copy the content of backups folder into data folder. This worked for me.
After this you have to reconfigure innodb files of your existent databases
I had the same issue. I had a backup of my C:\xampp\mysql\data folder. But integrating it with the newly installed xampp had issues. So I located the C:\xampp\mysql\bin\my.ini file and directed innodb_data_home_dir = "C:/xampp/mysql/data" to my backed-up data folder and it worked flawlessly.
None of the above solution works for me. After pasting your old mysql/data directory to your new xampp, Check if ibdata1 has all the permissions required by the current user otherwise try to grant the permissions. Then "Empty Session Data" in your phpmyadmin, solved my problem.
If you have tried all the above answers and yet failed, first try to fix your db by running this command,
mysqlcheck --repair my_db_name -u root -p
And then if issue fixed,
If not fixed and you have a backup of the table with you and not able to import it to the PHPMyAdmin, do the following.
1. Go to xampp\mysql\data\database_folder
2. Delete the files (with extension .frm and .ibd) starting with your table name. Eg: my_table.frm, my_table.ibd
3. Import your table
It worked for me.
I found the following answer at https://stackoverflow.com/a/66804621
helpful
If you are just moving your DB from one folder to another folder, but your InnoDB tables no longer work, because they can't be found and the error message "Table does not exist in the engine" is displayed, then these pair of SQL statements can be as quick as helpful:
ALTER TABLE __yourtable_name__ DISCARD TABLESPACE ;
ALTER TABLE __yourtable_name__ IMPORT TABLESPACE ;
In pratice, the .IDB file is detached from .FRM file and then bound again, so that table contents turn into readable.
It worked in my case. Hope yours too.
I also had same issue on my mac. I was running 5.3.0 version. I removed that version and installed 7.2.1 version. After this it is working in my case.
For me I removed whole data folder ( and took a backup ) from xampp\mysql\ and pasted data folder of previous one here which solved my problem...

In ''mysql'' Manager of pid file quit without update file

I am in a serious problem while installing mysql on ubuntu 12.04 32 bit. when i start mysql with command ''./mysql.server start'' I got this error Manager of pid file quit without updating pid file. I installed ''mysql-5.1.39-linux-i686-glibc23''.
I thoroughly search for the solution to fix this error but cannot resolve it yet. I copied my-medium.cnf file to the /etc directory and rename it by my.cnf also edited this file in the section ''The mysql Server'' and add these lines ''datadir = /exports/disk0/data'' but could fix this problem. Can any one help on this.
The message bout the pid file is kind of a red herring. It just means that the init script /etc/init.d/mysql did not return success. The root cause could be a variety of things, for example file permissions problems in your datadir, or the config file contained an invalid line, or dozens of other possible problems.
When you get the error about the pid file, the first thing you should do is to go read the MySQL error log file. Usually this is in the data directory, and it may be called hostname.err (where "hostname" is the name of the server you installed MySQL).
Search the file for any lines reporting "ERROR" and then use Google to research the error.

Uploading small .sql file to MySQL database file returns error (XAMPP on OS X)

I am running a fresh install of XAMPP 1.8.2 for OSX and am currently trying to upload an exported database that is 171kb in size.
Getting hit with this error
Warning: File upload error - unable to create a temporary file in Unknown on line 0
From what I have discovered it may have something to do with write permissions to a /tmp file which doesn't seem to exist on my system.
Trying to set this up so I can make changes locally on a clients website without breaking the live site.
Cheers and thanks for taking a look.
Solved
within the file uploads section of your php.ini there resides this:
;upload_tmp_dir =
To allow for uploads uncomment and give the tmp dir a home:
upload_tmp_dir = "/tmp"
The the most recent default installation of XAMPP on Lion has a couple of very important lines commented out (in regards to phpmyadmin/mysql). Not sure why, but I would love to learn the reasoning behind it.

Unable to write MySQL temp file when running Rails migration

UPDATE: The sysadmin in my company deleted the /tmp directory and created a
symbolic link to a mounted drive (e.g. ln -s /mnt/somewhere /tmp).
MySQL apparently didn't like this symbolic link.
Once a real /tmp directory on the local filesystem was created the problem went away.
I'm running a process (rake db:migrate) which causes MySQL to try to create a temp file.
However, the following error is appearing:
Mysql::Error: Can't create/write to file '/tmp/#sql_196_0.MYI' (Errcode: 13):
SHOW FIELDS FROM `user_rules`
Errcode 13 apparently is a file permission issue.
The user that is running the process has write permissions to the /tmp directory.
I also searched the web, and someone mentioned that the issue could be the file be prefixed with a pound sign (e.g. '#").
I went to the /tmp directory and tried to create the file and noticed that in certain cases I can't create the file. So I'm wondering if indeed the pound sign is causing the problem. And if it is, how can use MySQL or Rails to fix the problem:
cd /tmp
echo "Hello" > #sql_123
touch #sql_123
echo "Hello" > "#sql_123"
touch "#sql_123"
The 2nd and 3rd commands (without quotes) are failing. The 4th and 5th lines (with quotes) are working. So maybe the failure is because of the pound sign not being in quotes or escaped with a backslash. But again, even if that is the cause, I'm not sure how to tell MySQL or Rails how to deal with it.
Any ideas?
In a shell you need quotes because # introduces a comment, unless escaped by a backslash or quotes. Those #sql_123 files with a prefix of a pound-sign are temporary files owned by mysql, they are normal. You cannot move them however and whenever they are present you cannot move your database using the binary files, you either need to shutdown and move; or do a mysqldump to SQL.
Now for your sysadmin, did he delete /tmp while mysql was running? Mysql opens files in /tmp and then deletes them from the directory leaving the file-handle open. You would see differences in disk space while the server is up or down. MySQL creates all temporary files as hidden files. This ensures that the temporary files are removed if mysqld is terminated. The disadvantage of using hidden files is that you do not see a big temporary file that fills up the file system in which the temporary file directory is located.
So if you would like to keep the symlink (i.e. to a larger disk) then you would better shutdown mysql, create the link, and then start mysql to find it has no problem with symlinks.