MySQL data directory location - mysql

I installed MySQL on a Mac after downloading its DMG file version 64 bit.
While trying to create a database it gave me error 1006 -- can't create database. After browsing a number of website, it seems due to user ownership setting of MySQL "data directory" location that needs to be changed.
Where is MySQL default data directory? I could not find /var/lib/mysql in localhost.
THANKS.

If the software is Sequel pro the default install mysql on Mac OSX has data located here:
/usr/local/var/mysql

See if you have a file located under /etc/my.cnf. If so, it should tell you where the data directory is.
For example:
[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
...
My guess is that your mysql might be installed to /usr/local/mysql-XXX.
You may find these MySQL reference manual links useful:
Installing MySQL 8.0 on MacOS
Installing MySQL 5.7 on MacOS
Installing MySQL 5.6 on MacOS
Installing MySQL 5.5 on MacOS

As suggested, I edited this message to place a proper answer.
The 'physical' location of the MySQL database is under /usr/local/mysql
The mysql is a symlink to the current active MySQL installation, in my case the exact folder is mysql-5.6.10-osx10.7-x86_64.
Inside that folder you'll see another data folder, inside it are RESTRICTED folders with your databases.
You can't actually see the size of your databases (that was my issue) from the Finder because the folder are protected, you can though see from the terminal with sudo du -sh /usr/local/mysql/data/{your-database-name} and like this you'll get a nice formatted output with the size.
In those folder you have different files with all the folders present in your database, so it's safer to check the db's folder to get a size.
That's it. Enjoy!

Well, if yo don't know where is my.cnf (such Mac OS X installed with homebrew), or You are looking found others choices:
ps aux|grep mysql
abkrim 1160 0.0 0.2 2913068 26224 ?? R Tue04PM 0:14.63 /usr/local/opt/mariadb/bin/mysqld --basedir=/usr/local/opt/mariadb --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mariadb/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/iMac-2.local.err --pid-file=iMac-2.local.pid
You get datadir=/usr/local/var/mysql

On M1 and homebrew the "data directory" is:
/opt/homebrew/var/mysql
And the main path is:
/opt/homebrew/Cellar/mysql

Check where is the root folder of mysql with:
mysql_config

If you are using macOS {mine 'High Sierra'} and Installed XAMPP
You can find mysql data files;
Go to : /Applications/XAMPP/xamppfiles/var/mysql/

If you install MySQL via homebrew on MacOS, you might need to delete your old data directory /usr/local/var/mysql. Otherwise, it will fail during the initialization process with the following error:
==> /usr/local/Cellar/mysql/8.0.16/bin/mysqld --initialize-insecure --user=hohoho --basedir=/usr/local/Cellar/mysql/8.0.16 --datadir=/usr/local/var/mysql --tmpdir=/tmp
2019-07-17T16:30:51.828887Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.16/bin/mysqld (mysqld 8.0.16) initializing of server in progress as process 93487
2019-07-17T16:30:51.830375Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2019-07-17T16:30:51.830381Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it.
2019-07-17T16:30:51.830410Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-07-17T16:30:51.830540Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.16/bin/mysqld: Shutdown complete (mysqld 8.0.16) Homebrew.

If you are using Homebrew to install MySQL#5.7, the location is
/usr/local/Homebrew/var/mysql
I don't know if the location is the same for other versions.

Related

MySQL 8 W10 service works on install then won't start ater reboot

I've been going through upgrade hell changing to MySQL 8.0 on my W10 machine. Long story short, after difficulty upgrading the normal way I uninstalled the previous version and traces of it in Program Files, ProgramData, and Users[user]\Roaming\MySQL and did a fresh install of 8.0.x (latest version).
After the install the service started and worked fine. After a reboot, the service won't start and I get the "MySQL service on Local Computer has started and then stopped." error.
I have been through the fixes suggested in this thread, but the service still won't start. If I try to start the daemon manually I get:
C:\Users\boss>mysqld
2020-01-18T15:54:14.346428Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.19) starting as process 9236
2020-01-18T15:54:14.352531Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2020-01-18T15:54:14.352672Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2020-01-18T15:54:14.353206Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2020-01-18T15:54:14.368554Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-01-18T15:54:14.368725Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
There is a data folder under \ProgramData\MySQL Server 8.0 but not under \Program Files\MySQL\MySQL Server 8.0. I found another thread that suggested a fix by running mysqld --initialize but it also implied you don't need the folder under Program Files if you're running as a service, so I'm not sure this is the problem and don't want to make a change that will screw things up even more.
Can anyone advise me how to troubleshoot this?
UPDATE. Looking in the logfile I find error: "Fatal error: Could not read the column 'authentication_string' from table 'mysql.user'. Please perform the MySQL upgrade procedure." Now I think I know what happened. I installed the new version then read a dump file from the old version. That was a dump of the entire DB so when the server started and I restored this, it overwrote the mysql.user file. Question is, what can I do about this now? I can reinstall but how to I restore everything besides mysql.user from the dump file?
The last update was correct...I was overwriting the mysql files when I restored the dump. The solution was to open the dump file in an editor that could handle a file that big (NoteTab light) and delete the section containing the mysql statements.

The post-install step did not complete successfully MySQL Mac OS Sierra

[(pyEnv) Anants-MacBook-Pro:litibackend anantchandra$ brew postinstall mysql
==> Postinstalling mysql
==> /usr/local/Cellar/mysql/8.0.11/bin/mysqld --initialize-insecure --user=anantchandra --basedir=/usr/local/Cellar/mysql/8.0.11 --datadir=/usr/local/var/mysql --tmpdir=/tmp
Last 15 lines from /Users/anantchandra/Library/Logs/Homebrew/mysql/post_install.01.mysqld:
2018-06-15 04:41:04 -0700
/usr/local/Cellar/mysql/8.0.11/bin/mysqld
--initialize-insecure
--user=anantchandra
--basedir=/usr/local/Cellar/mysql/8.0.11
--datadir=/usr/local/var/mysql
--tmpdir=/tmp
2018-06-15T11:41:04.901191Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.11/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 37841
2018-06-15T11:41:04.903504Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-06-15T11:41:04.903537Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-06-15T11:41:04.903701Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.11/bin/mysqld: Shutdown complete (mysqld 8.0.11) Homebrew.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mysql`
I was able to go back to 5.7 for anyone who wants to:
brew uninstall mysql
brew install mysql#5.7
brew link --force mysql#5.7
mysql.server start
mysql_secure_installation
After all that, I'm back in 5.7 with all my databases intact. In my case, I knew the data in the databases wasn't crucial, so I didn't attempt to backup the data in advance. Worked fine for me. If you have irreplaceable data in your local databases, you might want to tread carefully. I didn't lose data, but I don't want anyone else to lose data on my advice either. ;)
Normally, I don't mind a MySQL upgrade, but 8.0 looks to have compatibility issues I'd like to vet before going forward, and in the meantime, I'd rather be back on a version that doesn't force me to deal with those issues.
The installation or re-installation, brew install mysql, created the default data directory, and the post installation does not handle it...
Simply move the existing data directory (this moves it to a sibling directory, named with the process id of the shell):
$ mv /usr/local/var/mysql /usr/local/var/mysql-$$
or might need super user privileges...
$ sudo mv /usr/local/var/mysql /usr/local/var/mysql-$$
Then run:
$ brew postinstall mysql
First, backup the content of your data directory: /usr/local/var/mysql by copying it to a safe place.
The error happens because the post-install script check if a file /usr/local/var/mysql/mysql/user.frm exists. For whatever reason you don't have this file. The postinstall script then tries to install a new MySQL 8 database by running mysqld with --initialize-insecure but as the directory already contains some data from MySQL 5.7 the script halts.
Here is the correspoding part of the script in mysql.rb:
def post_install
# Make sure the datadir exists
datadir.mkpath
unless (datadir/"mysql/user.frm").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end
There is several possible solutions. If you can still run your MySQL 5.7 database, export everything with mysqldump then install a fresh MySQL 8 database by removing all content in /usr/local/var/mysql and then import everything back again. Another solution, is to use the mysql_upgrade tool.
P.S.: Personally, I use the formula mysql#5.7 and I will in the future switch to MariaDB.
According to this link, below command saves me on macOS Mojave:
sudo chown -R $(whoami) /usr/local/*

Can't create test file lower test start server mysql

I'm following this tutorial here on creating a JDBC programming. I've followed the steps up to the console command to start the server:
// For Windows
cd {path-to-mysql-bin} // Check your MySQL installed directory
mysqld --console
I get the following error message:
mysqld: Can't change dir to 'C:\Program Files\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory)
2017-01-06T10:54:36.968210Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-06T10:54:36.968210Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-01-06T10:54:36.968210Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 11248 ...
2017-01-06T10:54:36.974226Z 0 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-DEQ2IC2.lower-test
2017-01-06T10:54:36.975229Z 0 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-DEQ2IC2.lower-test
2017-01-06T10:54:36.975229Z 0 [ERROR] failed to set datadir to C:\Program Files\MySQL\MySQL Server 5.7\data\
2017-01-06T10:54:36.976231Z 0 [ERROR] Aborting
2017-01-06T10:54:36.977234Z 0 [Note] Binlog end
2017-01-06T10:54:36.978237Z 0 [Note] mysqld: Shutdown complete
I'm quite new to using MySql in this way but I can see that there is no data folder in the server directory and no my.ini file which I assumes holds the config information on where the data directory is. I've also insntalled MySql using the windows installer which I've read could be why there is no my.ini file and just a template my-default.ini file.
Does anyone know why this is happening?
Create a data folder in C:\Program Files\MySQL\MySQL Server 8.0.
Create a new file with
(ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';)
command for password reset (if required)
Make sure that your file is in C: drive. root folder.
Then execute the below command:
C:\> cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
C:\> mysqld --init-file=C:\\mysql-init.txt
As mentioned above, create a "data" folder, (for me after that it didn't show errors, but it wasn't stills starting).
After that, go to services.msc in windows and start it from there. Also set it to Automatic so it starts automatically whenever you start the windows.
It worked for me.
If you install MySQL using the MySQL installation wizard your executable path is where you installed. It's something like "C:\Program Files\MySQL\MySQL Server 8.0\bin". Your my.init file resides in ProgramData, and path for init file may be like "C:\ProgramData\MySQL\MySQL Server 8.0". If it's can't be viewed in the location, please check whether it's hide.
As in your error description "Can't create test file C:\Program Files\MySQL\MySQL Server 5.7\data...", It seems there is no folder named 'data' in MySQL installed location. Most probably It may reside where the 'my.init' file exists (ProgramData). Else may be the name of the folder not 'data' but 'Data'.
You can copy the Data folder from the location of init-file exist and paste to the executable location. Also, change the name of the folder to data if it's capitalized.
I ran the command bin\mysqld --initialize --console and everything was solved. In some cases the data folder should be created before.
There are different parameters for windows and the rest.
See the following links:
https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html
https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html#data-directory-initialization-password-assignment
https://dev.mysql.com/doc/refman/8.0/en/option-files.html
In my case, I installed MySQL with Windows installer on the D:/ drive and was set NOT to run as Windows service.
I managed to resolve the issue by moving my.ini from C:\ProgramData\MySQL\MySQL Server 8.0 to MySQL installation folder.
This error happens to me.
The solution was edit D:\Program Files\xampp\mysql\data\my.ini and change the directory to your D: path
[mysqld]
datadir=D:\program files\xampp\mysql\data
[client]
I could solve it; I had similar issues.
C:\Program Files\MySQL\MySQL Server 8.0\bin>**mysqld --console**
2021-02-27T23:46:09.919345Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.23) starting as process 7296
2021-02-27T23:46:09.926583Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2021-02-27T23:46:09.926798Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2021-02-27T23:46:09.927086Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2021-02-27T23:46:09.933751Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-02-27T23:46:09.934110Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
The solution was that I needed to recreate the my.ini file in C:\ProgramData\MySQL\MySQL Server 8.0 and add to this:
[mysqld]
datadir=C:\ProgramData\MySQL\MySQL Server 8.0\Data
Set encoding to ANSI and saved the file.
Then the service could start:
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80
Installing with a new MSI installer also didn't solve the issue, it kept hanging until I made the above mentioned adaptations.
In my case, the data folder did not exists, so I created one and things started working.
For xampp-portable-windows-x64-8.0.8-0-VS16
It worked by just putting at root of drive as mentioned in \ xampp \ readme_en.txt
NOTE: Unpack the package to your USB stick or a partition of your choice.
There it must be on the highest level like E:\ or W:\.
Hopes that helps
I stumbled on the same problem as mentioned at the beginning of this thread, and the trick for me was to run my console on Administrator mode (windows).
The error messages related to things like "can't find the folder" etc.., were due to the unability for the program to create, on demand, such folders and files.
Cheers
That happened to me when I try to launch the server without being in admin mode. Try relaunching console in admin mode and then navigate to the sql server 8.0 directory before trying again

mysqld: Can't change dir to data. Server doesn't start

I installed a MySQL server with installer and it started. After reboot I tried to start it again and get the error:
D:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld -u root -p
mysqld: Can't change dir to 'D:\Program Files\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory)
2015-11-17T08:30:18.822962Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-17T08:30:18.822962Z 0 [Warning] Insecure configuration for --secure- file -priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2015-11-17T08:30:18.822962Z 0 [Note] mysqld (mysqld 5.7.9) starting as process 1108 ...
2015-11-17T08:30:18.838586Z 0 [Warning] Can't create test file D:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-RNBR3E8.lower-test
2015-11-17T08:30:18.838586Z 0 [Warning] Can't create test file D:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-RNBR3E8.lower-test
2015-11-17T08:30:18.838586Z 0 [ERROR] failed to set datadir to D:\Program Files\MySQL\MySQL Server 5.7\data\
2015-11-17T08:30:18.838586Z 0 [ERROR] Aborting
2015-11-17T08:30:18.838586Z 0 [Note] Binlog end
2015-11-17T08:30:18.838586Z 0 [Note] mysqld: Shutdown complete
I tried to reinstall MySQL.
UPDATE:
When I run mysqld -u root -p as administrator, nothing happens.
I have met same problem. In my case I had no ..\data dir in my C:\mysql\ so I just executed mysqld --initialize command from c:\mysql\bin\ directory and I got the data directory in c:\mysql\data. Afterwards I could use mysqld.exe --console command to test the server startup.
Since you used the Windows installer, everything is set up for you to run MySQL 5.7 as a Windows service, which is a great option in most cases.
Instead of running mysqld.exe from the command line,
Win + R
Run services.msc
Right-click on MySQL57
Start the service.
In my case, I had installed the data directory to a different location. So the data directory really wasn't in the default location. Therefore, when I ran the mysqld command from the command prompt, I had to specify the data directory manually:
mysqld --datadir=D:/MySQLData/Data
Here's the documentation for mysqld command-line arguments.
First run
mysqld -u root --initialize-insecure
It will create data folder with root as user without password. Then run
mysqld.exe -u root --console
What I did (Windows 10) for a new installation:
Start cmd in admin mode (run as administrator by hitting windows key, typing cmd, right clicking on it and selecting "Run as Administrator"
Change into "MySQL Server X.Y" directory (for me the full path is C:\Program Files\MySQL\MySQL Server 5.7")
using notepad create a my.ini with a mysqld section that points at your data directory
[mysqld]
datadir="X:\Your Directory Path and Name"
created the directory identified in my.ini above.
change into bin Directory under server directory and execute:
mysqld --initialize
Once complete, started the service and it came up fine.
Check that the director exists.
If it exists make sure mysql has access rights on it (read/write). Can be a good idea to run MySQL as a system process, but not mandatory.
If this is stil not working try having the following notation with double slashes: C:\WebSerer\MySQL\data or C:/WebServer/MySQL/data
If you are having this issue and can't find the MySQL service either, just launch "MySQL Installer" from the Start menu (or download it), then choose "Reconfigure" on MySQL Server. Follow the steps to set a root user password and then the service will be created and started automatically (and set to auto-start on boot).
In mysql 8.0.13 zip package initializing.
Verify that data folder is empty.
Under the mysql bin path run
mysqld.exe --initialize-insecure
Add to my.ini native mysql
[mysqld]
default_authentication_plugin=mysql_native_password
When I encountered this same error, I noticed MySQL Configuration file in "C:\Program Files\MySQL\MySQL Server X.Y\" has changed to my-default.ini
I solved it by
Copy my.ini from "C:\ProgramData\MySQL\MySQL Server X.Y\my.ini"
Paste it in "C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
Restart MySQL Server from services.msc
In the .ini file, their is part that reads:
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
Check your real my.ini file location and set --defaults-file="location" with this command
mysql --defaults-file="C:\MYSQL\my.ini" -u root -p
This solution is permanently for your cmd Screen.
remove all files in "{path-to-mysql}\data" directory and run:
mysqld --initialize-insecure --basedir={path-to-mysql}\mysql --datadir={path-to-mysql}\data --console
I don't know if it's your problem but try this...
For me, the version of my.ini which is created under "ProgramData\MySQL\MySQL Server [version]" wasn't read. I had to move it to "Program Files\MySQL\MySQL Server [version]".
RTS.
If you installed MySQL Server using the Windows installer and as a Window's service, then you can start MySQL Server using PowerShell and experience the convenience of not leaving the command line.
Open PowerShell and run the following command:
Get-Service *sql*
A list of MySQL services will be retrieved and displayed. Choose the one that you want and run the following command while replacing service-name with the actual service name:
Start-Service -Name service-name
Done. You can check that the service is running by running the command Get-Service *sql* again and checking the status of the service.
mariofertc completely solved this for me here are his steps:
Verify mysql's data directory is empty (before you delete it though, save the err file for your records).
Under the mysql bin path run:
mysqld.exe --initialize-insecure
add to my.ini (mysql's configuration file) the following:
[mysqld]
default_authentication_plugin=mysql_native_password
Then check services (via task manager) to make sure MySql is running, if not - right click MySql and start it.
I'll also note, if you don't have your mysql configuration file in the mysql bin and can't find it via the windows search, you will want to look for it in C:\Program Data\Mysql\ Note that it might be a different name other than my.ini, like a template, as Heesu mentions here: Can't find my.ini (mysql 5.7)
Just find the template that matches the version of your mysql via the command mysql --version
This solution uses the windows mysql installer.
I have tried every other way mentioned here and other related posts, but it did not solve my problem, the service just wont start, but the below approach with the mysql-installer did.
If you still have your installer or atleast remember the version then follow below steps:
Start your windows mysql installer. For me it was "mysql-installer-community-8.0.20.0"
Then remove/uninstall the SQL Server and remove all configurations
Manually delete the SQL Server folder from "C:\Program Files\MySQL\MySQL Server 8.0."
Start your mysql installer again and install the SQL Server again
You can check from the window's services that the MySqL Server has started.
Hope it helps someone.
Check for missing folders that are required by the server, in my case it was UPLOADS folder in programData which was deleted by empty folder cleaner utility that I used earlier.
How did I find out:
run the server config file my.ini(in my case it was in programData) as the defaults-file param for mysqld (don't forget to use --console option to view error log on screen)
'mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console'
Error:
mysqld: Can't read dir of 'C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\' (OS errno 2 - No such file or directory)
Solution:
Once I manually created the Uploads folder the server started successfully.
In my case, I'm MySQL5.6, install by workbrench install tools in Win10 pro.
there are two configuration file need to modify,
only edit the line: datadir=E:\MySQL
stop MySQL56 service using services.msc
edit my.ini under C:\ProgramData\MySQL\MySQL Server 5.6
edit my-default.ini under C:\Program Files\MySQL\MySQL Server 5.6
copy C:\ProgramData\MySQL\MySQL Server 5.6*.* to E:\MySQL
start MySQL56 service using services.msc
test: create database 'testdb';
It's successed if found testdb folder exist in E:\MySQL.

MySQL on ubuntu 12.04 won't run after MySQL Workbench installed

Recently I installed MySQL Workbench 6.2 and used it to create ER diagrams of the MySQL 5.5.41 databases I'm working with on Ubuntu 12.04. Everything worked fine until I restarted Ubuntu and suddenly mysql was no longer running. Running mysqld from the command line results in this:
150216 12:50:37 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
150216 12:50:37 [Warning] Can't create test file /var/lib/mysql/euler.lower-test
150216 12:50:37 [Warning] Can't create test file /var/lib/mysql/euler.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
150216 12:50:37 [ERROR] Aborting
150216 12:50:37 [Note]
The file /usr/share/mysql/english/errmsg.sys exists, owned by root, with permissions 644. The directory /var/lib/mysql exists, owned by mysql, with permissions 700.
I'm guessing that the installation of Workbench changed something (maybe config files) so that mysql is no longer working, but after a fair amount of Internet research, I have not discovered how to solve this problem. Any help will be greatly appreciated.
Seems like file permission problem. Try running mysqld again using sudo
If this doesn't help, maybe you shouldn't be starting it directly via mysqld. Check if the installer package added a service
sudo service --status-all | grep mysql
And if one exist, use it to start mysql, typically:
sudo service mysqld start
Also don't forget to check if mysqld is already running. If so you can't start duplicate process. I know this sound silly but has happened to me before
ps -ef | grep mysqld