In this article, we will see how to resolve sudo mysql_secure_installation: command not found error. mysql_secure_installation is a shell script used on Linux and Unix-based systems to strengthen the security of the MySQL and MariaDB database. It comes by default with the installation of MySQL and MariaDB. So if you don’t have the database packages installed on your system, chances are mysql_secure_installation script isn’t available either. In that case, if you try to run the script, you will always end up with the error sudo mysql_secure_installation: command not found.
Along with this, in some of the cases there could be some other reasons as well for the sudo mysql_secure_installation: command not found error. Here we will look at all those cases along with the steps to resolve the error in the next section.
<img src
="https://www.cyberithub.com/wp-content/uploads/2023/02/mysql_secure.jpg" alt="Solved "sudo mysql_secure_installation : command not found"" /> Solved "
sudo mysql_secure_installation : command not found
"
Also read: Solved "Unable to run binary file: Exec format error"
As stated above, when you try to run the sudo mysql_secure_installation command without installing MySQL or MariaDB packages, you will then see an error in the output.
cyberithub@ubuntu:~$ sudo mysql_secure_installation sudo: mysql_secure_installation: command not found
To fix the above error, you must first update and update the system packages to the latest version using the sudo apt update
&& sudo apt upgrade command as shown below. cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade Hit:2 stable https://dl.google.com/linux/chrome/deb InRelease Hit:3 http://security.ubuntu.com/ubuntu focal security InRelease Hit:4 focal http://in.archive.ubuntu.com/ubuntu InRelease Hit:5 https://deb.tableplus.com/debian/20 tableplus InRelease Hit:6 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:7 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:1 https://downloads.apache.org/cassandra/debian 40x InRelease Reading package lists… Done Creation of dependency tree Reading status information… Made 17 packages can be upgraded. Run ‘apt list -updatable’ to view them. Reading package lists… Done Creation of dependency tree Reading status information… Done Calculating the update… Done The following packages were installed automatically and are no longer needed: dctrl-tools gir1.2-gee-0.8 gir1.2-gtksource-3.0 gir1.2-harfbuzz-0.0 libatk-bridge2.0-dev libatk1.0-dev libatspi2.0-dev libblkid-dev libcairo-script-interpreter2 libcairo2-dev libdatrie-dev libdbus-1-dev libegl-dev libegl1-mesa-dev libepoxy-dev libexpat1-dev libffi-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev libfribidi-dev libgdk-pixbuf2.0-dev libgee-0.8-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglib2.0-dev libglib2.0-dev-bin libglvnd-dev libglx-dev libgraphite2-dev libgtk-3-dev libgtksourceview-3.0-1 libgtksourceview-3.0-common …………….
Then you need to install mysql server using the sudo apt install mysql-server mysql-client command as shown below.
cyberithub@ubuntu:~$ sudo apt install mysql-server mysql-client [sudo] password for cyberithub: Reading package lists… Done Creation of dependency tree Reading status information… Done The following packages were installed automatically and are no longer needed: dctrl-tools gir1.2-gee-0.8 gir1.2-gtksource-3.0 gir1.2-harfbuzz-0.0 libatk-bridge2.0-dev libatk1.0-dev libatspi2.0-dev libblkid-dev libcairo-script-interpreter2 libcairo2-dev libdatrie-dev libdbus-1-dev libegl-dev libegl1-mesa-dev libepoxy-dev libexpat1-dev libffi-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev libfribidi-dev libgdk-pixbuf2.0-dev libgee-0.8-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglib2.0-dev libglib2.0-dev-bin libglvnd-dev libglx-dev libgraphite2-dev libgtk-3-dev libgtksourceview-3.0-1 libgtksourceview-3.0-common libgtksourceview-3.0-dev libharfbuzz-dev libharfbuzz-gobject0 libice-dev libmount-dev libopengl-dev libpango1.0-dev libpcre16-3 libpcre2-16-0 …………
In case you want to use MariaDB instead of MySQL, you can install it by running the command sudo apt install mariadb-server mariadb-client as shown below.
cyberithub@ubuntu:~$ sudo apt install mariadb-server mariadb-client Reading package lists… Done Creation of dependency tree Reading status information… Done The following additional packages will be installed: galley-3 libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libfcgi-perl libhtml-template-perl libreadline5 libsnappy1v5 libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 socat Suggested packages: libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test tinyca The following NEW packages will be installed: galera-3 libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libfcgi-perl libhtml-template-perl libreadline5 libsnappy1v5 libterm-readkey-perl mariadb-client mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 socat 0 updated, 20 newly installed, 0 to remove and 0 not updated. You need to get 20.0 MB of files. After this operation, 167 MB of additional disk space will be used. Do you want to continue? [Y/n] And……………………………………..
After a successful installation, if you now try to run the sudo command mysql_secure_installation again, this time it will work as below.
cyberithub@ubuntu:~$ sudo mysql_secure_installation Secure MySQL server deployment. Connect to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of the password and allows users to set only those passwords that are strong enough. Do you want to configure the VALIDATE PASSWORD component? Press y| And for Yes, any other key to No: …………
If even after following the previous steps, you still receive the same error, there is a chance that the database files are installed in a path that is currently not visible to the system. Therefore, in that case, you must specify the custom path in the global PATH environment variable so that the system knows the path of the database files. Once added, restart the system once to reflect the changes in all user profiles on the system. Then try running sudo mysql_secure_installation command again. It should work successfully.
I hope the above solution is enough to solve your problem. Please let me know your comments in the comment box!!