How to resolve FATAL ERROR: Could not find /usr/bin/mysql mariadb on Arch/Manjaro Linux? - mysql

I am accidentally delete /usr/bin/mysql from my directory. It make an error when I run mysql_secure_installation and produce following error message.
FATAL ERROR: Could not find /usr/bin/mysql
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 have already tried to uninstall mariadb using sudo pacman -Rns mariadb and installing it again, but /usr/bin/mysql not generate. Are someone already face same problem before ?

Related

error while creating multiple mysql servers on same ubuntu machine

While creating multiple mysql servers on same ubuntu machine under EC2 instance on AWS.I successfully created /var/lib/mysql2 , /var/log/mysql2 ,/etc/mysql2/
done desired changes in my.cnf file(under /etc/mysql2/ which i created by just copying /etc/mysql/ content) along with desired rights to mysql user
(Reference used to do the needful :--
- http://www.ducea.com/2009/01/19/running-multiple-instances-of-mysql-on-the-same-machine/
)
After running the following
sed -i 's/3306/3307/g' my.cnf
sed -i 's/mysqld.sock/mysqld2.sock/g' my.cnf
sed -i 's/mysqld.pid/mysqld2.pid/g' my.cnf
sed -i 's/var\/lib\/mysql/var\/lib\/mysql2/g' my.cnf
sed -i 's/var\/log\/mysql/var\/log\/mysql2/g' my.cnf
Proceeded by running the following command where i am getting error
mysql_install_db --user=mysql --datadir=/var/lib/mysql2/
Error:--->
FATAL ERROR: Could not find my-default.cnf file in my system and found the path
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 tried to do the following but in vain
sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql2/ --basedir=/usr/share/doc/mysql-server-5.6/examples/
FATAL ERROR: Could not find /fill_help_tables.sql
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.
Please help in resolving the issue.I have installed MySQL server 5.6 and want to use the same version for my another instance on 3307 port

configure: error: invalid MySQL root directory

I've a problem installing sphinx with percona 5.6 on centos 6.4.
I'm getting the following error while building from source:
******************************************************************************
ERROR: cannot find MySQL include files.
Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.
If include files are installed on your system, but you are still getting
this message, you should do one of the following:
1) either specify includes location explicitly, using --with-mysql-includes;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in
your PATH environment variable.
To disable MySQL support, use --without-mysql option.
******************************************************************************
Percona-Server-devel is installed:
rpm -qa | grep -i percona
percona-release-0.0-1.x86_64
Percona-Server-server-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-client-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-devel-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-shared-56-5.6.16-rel64.2.el6.x86_64
What I've tried:
locate "libmysql"
/usr/lib64/libmysqlclient.so.18
/usr/lib64/libmysqlclient.so.18.0.0
/usr/lib64/libmysqlclient_r.so.18
/usr/lib64/libmysqlclient_r.so.18.0.0
/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient_r.so.16
/usr/lib64/mysql/libmysqlclient_r.so.16.0.0
/usr/lib64/mysql/libmysqlservices.a
than:
./configure --with-mysql=/usr/lib64/mysql --with-mysql-libs=/usr/lib64/mysql
./configure --with-mysql=/usr/lib64 --with-mysql-libs=/usr/lib64
./configure --with-mysql=/usr/bin/mysql --with-mysql-libs=/usr/bin/mysql
./configure --with-mysql=/usr
configure: error: invalid MySQL root directory '/usr/lib64/mysql';
neither bin/mysql_config, nor include/ and lib/ were found there
which mysql_config
/usr/bin/mysql_config
Have you tried installing mysql-devel ?
sudo yum install mysql-devel
If properly setup, try as suggested in the error message to point to these libs manually using a command like the following one (to be adapted to your environment)
./configure --with-mysql-includes=/usr/local/src/mysql-XXX/include

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 cannot find file

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"

Cannot find MySQL -- get "command not found" error when trying to access MySQL from command line

I have previously installed, connected and uploaded to a WordPress MySQL database via SSH no problem. The people who run my server made a few configuration changes, and now I get a "bash: mysql: command not found" error when I try to log into MySQL via the command line on the same server to access the same database.
I am relatively new to all of this, so I am really not sure what to do. When I run "which mysql" I get a message that says there is no MySQL executable in the /usr/bin directories. I can verify that MySQL is running between the fact that my site is still live and functioning and when I ran a command to test MySQL, I got a message that said "MySQL works!"
I find MySQL files in several directories, but I'm not really sure what I am looking for and how I connect to it when I do find it. I am also not sure if this is user error, or if somehow someone moved or hid MySQL from me -- likely user error??
A MySQL server is not a MySQL client.
Check if MySQL is running by executing this command:
ps aux | grep mysql | grep -v grep
And install the MySQL client:
sudo apt-get install mysql-client # Or your distribution command
If you have MySQL server up and running on your server, it does not mean you have a MySQL client installed on this server.
Try
ls -l /usr/bin/mysql*
Do you see MySQL binaries exactly present on system?
One more problem: Linux has very strange behaviour when you run binaries for another architecture.
For example, if you run a 32-bit executable on 64-bit system you will get an error message like "command or file not found", even if the binaries are actually present!
Now mysql-client has changed to default-mysql-client.
Hence the command:
sudo apt-get install default-mysql-client
Although MySQL is running, if you are not able to connect to the server using the mysql command, then you might be missing to provide soft links:
sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
sudo ln -s /usr/local/mysql/bin/mysql /usr/bin
This should enable you to connect.
In order to get MySQL CLI working or to access the mysql command from anywhere, there are a set of steps to be done to add it to the $PATH variable.
First, open a terminal, and run the following command
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
Then to reload the Bash profile, run
. ~/.bash_profile
Now run,
mysql -u root -p
Enter the password which you gave during installation. You should see the following result:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.23 MySQL Community Server - GPL
You sometimes need to install MySQL on the local machine as well. That means, if you have a host running a MySQL Docker container, the strange thing happened to me that I needed to install mysql-server on the host as well, not only in the container.
The reason was that there was a shell script that needed to check the right database name from a query. In your case, it might be something different. On your host machine (which might even be your local computer, depending the your setup), if on Linux, try:
sudo apt-get update && sudo apt-get install mysql-server
Then you will get rid of
/home/.../some_bash_script.sh: line 123: mysql: command not found