Mysql_install_db cannot find file - mysql

I am trying to use mysql_install_db
I am getting the following error:
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
I've tried using
which my_print_defaults
It returns:
/usr/local/bin/my_print_defaults
So I try the command:
mysql_install_db --base-dir=/usr/local/bin/
I still receive the same error, though.

Annoyingly, this just means you have to be in the right directory to execute this. Make sure you're in /usr/local/Cellar/mysql/<version>/ before running the script.

You must run the command:
# mysql_install_db --basedir=/usr/local
That is without bin. This option must specify a directory path location of the directory ./bin.

Anyone reading this after installing MySQL with Homebrew may have experienced this issue:
https://stackoverflow.com/questions/4788381/getting-cant-connect-through-socket-tmp-mysql-when-installing-mysql-on-m
And then found their way here after the final instruction didn't work. I simply ran
mysql.server start
after reading http://benjsicam.me/blog/how-to-install-mysql-on-mac-os-x-using-homebrew-tutorial
Then it all started working miraculously (seems I just hadn't started it?!).

If you use Brew, try to run mysql_install_db with --basedir="$(brew --prefix mariadb)"
Change mariadb to mysql if you use mysql.

For me the fix was to point basedir to the actual mysql directory in the cellar, as shown at install.
eg:
During installation of mysql (using brew install mysql56), I was shown this path: /usr/local/Cellar/mysql56/5.6.27/bin/mysql_install_db...
I used that to define the basedir like so:
mysql_install_db --verbose --user=`whoami` --basedir="/usr/local/Cellar/mysql56/5.6.27" --datadir=/usr/local/var/mysql --tmpdir=/tmp

gotta add the path of mysql installation in system path
try: sudo path=${PATH}:/usr/local/mysql/bin
if you installed mysql in "/usr/local/mysql"

Related

MariaDB cannot start after update: [Warning] Can't create test file /home/mysql/beta.lower-test

I've just updated MariaDB using apt-get dist-upgrade. Now it won't start using service mysql start anymore.
I can however, run it as root or do: sudo -u mysql mysqld_safe then MariaDB starts up fine. The folder /home/mysql is owned by the mysql user and group.
I've found the error to be thrown in this function:
https://github.com/MariaDB/server/blob/7ff44b1a832b005264994cbdfc52f93f69b92cdc/sql/mysqld.cc#L9865
I can't figure out what to do next. Any pointers?
To run MariaDB SQL from /home, in the file /usr/lib/systemd/system/mariadb.service or /lib/systemd/system/mariadb.service, just change :
ProtectHome=true
to :
ProtectHome=false
The answer by Thomas is correct, but get's reset by updates every few months. So here is a permanent solution:
Use systemctl edit mariadb to create a file overwritting the default settings of the mariadb service. (In debian it's located in /etc/systemd/system/mariadb.service.d/override.conf)
Set the same setting Thomas changed in the file:
[Service]
ProtectHome=false
Use systemctl daemon-reload to reload the systemctl config.
On debian 9 you need to change ProtectHome to false in both /lib/systemd/system/mariadb.service and /lib/systemd/system/mariadb#.service then run sudo systemctl daemon-reload.
Maybe also run sudo grep -Ri "protecthome" /lib/systemd/system to find other instances of ProtectHome in mysql-related files if this still isn't working
The workaround for this is mounting the directory in home as /var/lib/mysql:
mount --bind /home/mysql/var/lib/mysql /var/lib/mysql
Same situation after update on Debian 8 (Jessie) and 9 (Stretch). After "apt-get upgrade" the command
service mysql start
the server fails to start and logs error:
[Warning] Can't create test file /home/johndoe/UserDatabases/mypcname.lower-test
the solution is to change in file /lib/systemd/system/mariadb.service the value:
ProtectHome=true
to
ProtectHome=false
as described above.
#RedGiant yes I solved it. Forgot to post here.
Apparently after the .1 release you cannot run SQL from /home anymore. There's probably a way around this but haven't found it.
I can run MySQL from any location except /home. What I did was unmount /home (I had my SSD RAID mounted to /home) and re-mount my disk as /ssd. Changed my paths in the config and it worked right away.
I did not run SELinux or Apparmor.
I have faced the same issue as mentioned in the question. In my case, I wanted to move the MariaDB Data Directory to the /home/mysql folder but after changing the my.cnf file, MariaDB service was failing to start.
I have made the following changes in the file /lib/systemd/system/mariadb.service
ProtectHome=true to ProtectHome=false
It asked me to reload the daemon while starting the Mariadb service again. However, i have rebooted the server and started the MariaDB service without any issue.

mysql command not found after homebrew mysql55 upgrade to 5.5

I've been running mysql55 (5.5.30) under homebrew for a while, and yesterday I updated it to 5.5.44 using brew upgrade mysql55. Now, I am unable to log into mysql or even get it running. Important notes:
1) After running, I got the The post-install step did not complete successfully
You can try again using 'brew postinstall homebrew/versions/mysql55' and This formula is keg-only, which means it was not symlinked into /usr/local. message. Running the suggested command doesn't seem to do anything.
2) Running mysql.server start worked fine before. Now I get command not found when I try to run any mysql command. I also ran launchctl unload and then load on the plist file. I can start mysql using /usr/local/opt/mysql55/bin/mysql but I can't connect with my client using /tmp/mysql.sock (I get access denied). I tried adding /tmp/mysql.sock, but that doesn't make a difference.
3) My current data is stored in /usr/local/var/mysql (it has directories for all my current dbs), but there is a new /user/local/var/mysql55 directory with the default test, mysql, and performance_schema directories.
4) I tried modifying the mysql55.plist file to point to /usr/local/var/mysql as the data dir, and unloading and loading it again with launchctl, but I still get nothing.
5) My path has /usr/local, and the only difference I can see between now and pre-upgrade is the new data directory. The output from brew upgrade shows the command /usr/local/Cellar/mysql55/5.5.44/bin/mysql_install_db --verbose --user=steve --basedir=/usr/local/Cellar/mysql55/5.5.44 --datadir=/usr/local/var/mysql55 --tmpdir=/tmp was run. I modified it to point to the current data dir (--data-dir=/usr/local/var/mmysql), and it seemed to run ok, but I still don't get anything when I run mysql. The previous version was 5.5.30, so it seems that something is still linked to that directory.
What do I need to do just to get mysql.server to work again, using my current data directory of /usr/local/var/mysql?
Thanks.
I ran the mysql_install_db a couple times with --datadir=/usr/local/var/mysql to no effect, so I ended up just adding
basedir = /usr/local/Cellar/mysql55/5.5.44
datadir = /usr/local/var/mysql
to /etc/my.cnf, and it finds the data directory fine now.

Error running mysql_install_db: could not find ./bin/my_print_defaults

I seem to be having an issue getting MySQL 5.6.1.5 to install from Source. I am running RHEL 6.
I was able to perform the cmake, make, and make install without issues.
I am attempting to run the mysql_install_db binary and when I do I get the following error:
Fatal ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to copy the software
into the correct location ready for operation.
If you are using a binary release, you must either bat at the top level of the
extracted archive, or pass the --basedir option pointing to that location.
So I did a check for my_print_defaults using which my_print_defaults, unfortunately it was not found on my machine.
I did a locate my_print_defaults as well just for the heck of it and said it was located in /usr/bin/my_print_defaults, however, when I checked /usr/bin for the binary, it was not actually there.
I would try to use mysql_install_db --basedir=/usr/bin but I know this won't work as the which and locate commands confirm my_print_defaults isn't on my machine.
I looked at mysql_install_db giving error, but that error was not similar to this one.
Please ignore question, I didn't bother to try running find / -name my_print_defaults and found it in /usr/local/mysql/bin/
I searched packages for my_print_defaults with
apt-file search my_print_defaults
If my_print_defaults is missing on your system (which my_print_defaults), first find out which db is installed with:
dpkg -l |grep -E 'maria|mysql'|grep ii|grep server
If you have installed mariadb, try reinstall mariadb:
sudo apt install --reinstall mariadb-server-core-10.1
If you don't find a solution with mariadb, swap back to mysql with
sudo apt install mysql-server

mysql_install_db gives FATAL ERROR: Could not find my-default.cnf

I've download MySQL and I'm trying to setup the MySQL grant tables, but when I type:
scripts/mysql_install_db --basedir=/usr/local
I get the error above.
I'm not sure how to fix it, as my-default.cnf is in the support_files directory and I believe I'm setting the basedir correctly.
(This is on mac btw)
(I'm assuming you're using Homebrew, since I hit the same issue trying to do the same thing on Homebrew on my macbook)
I believe you need to point it to the actual mysql directory in the cellar as its basedir, not at /usr/local (since that's just things symlinked from the cellar dir).
So, in my case, I had to use:
$ mysql_install_db --basedir=/usr/local/Cellar/mysql/5.6.10
Need copy /usr/share/my.cnf
Try this:
sudo cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf
sudo mysql_install_db
Its help for me on Ubuntu 14.04 and mysql 5.6.33
To extend to rascalking's answer, the current mysql installs to /usr/local/mysql/ via brew.
But to get over timestamp issue and the permission issue the full command will be:
sudo mysql_install_db --basedir=/usr/local/mysql --explicit_defaults_for_timestamp
Don't forget to set your password first incase you skipped the instruction:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

MySQL Mac OS X Problems

something strange is happening while trying to run MySQL server on my MacBook Air.
First ill installed MySQL using brew install mysql. Installation was successful without any errors.
And then problems started to showing up...
First i had to use following command in order to create empty tables:
cd /usr/local
sudo mysql_install_db --user=mysql --ldata=/var/db/mysql
Now im trying to launch the server service itself, but another error is not allowing me to do it:
ivankutsarov$ sudo mysql.server start
Password:
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Ivans-MacBook-Air.local.pid).
While ill navigate to the mentioned folder i cant see mysql folder in it, neither i can see it in my /usr/local/bin directory.
Any ideas guys?
Guys i found the problem. I forgot to run these 2 commands after installing mysql:
First, run: brew help mysql
Read the info displayed after command was executed, and you will notice in the first 2 lines the following commands which are necessary to run in order to start your server!
1.
unset TMPDIR
2.
mysql_install_db --verbose --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
I had a similar problem a day ago. mysql functioned fine until out of the blue PID file errors occur. I tried everything to fix the installation, replacing a dozen of files and trying many different settings.
what eventually worked was a clean install of mysql via the dmg package and a migration of my data&schema's to this install (use mysql workbench for this to save time), then uninstalled the version installed via brew.
https://dev.mysql.com/downloads/file/?id=466265