[Email protected]~]# mysql-u Root
-bash:mysql:command not found
Reason:
This is because the system will find the default command under/usr/bin, if this command is not in this directory, of course, will not find the command, we need to do is to map a link to the/usr/bin directory, equivalent to create a link file.
First you need to know the full path of the MySQL command or mysqladmin command;
[[Email protected]40271~]#PS-ef|grepMySQL Root the 1 0Jan18?xx:xx:xx/bin/SH/usr/local/mysql/bin/mysqld_safe--datadir=/data/mysql--pid-file=/data/mysql/ebs-40271. Pidmysql1627 the 0Jan18? ,: +: the/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/data/mysql/ebs-40271. err--pid-file=/data/mysql/ebs-40271. Pidroot24556 24484 2 -: -pts/1 xx: on: OneMysql-uroot-Proot24733 24715 0 the: thepts/3 xx:xx:xx grepMysql
Usr/bin/mysql refers to: The running path of MySQL
Var/lib/mysql refers to: The storage path of MySQL database files
Usr/lib/mysql refers to: MySQL installation path
For example, the path to MySQL is:/usr/local/mysql/bin/mysql, we can execute the command:
[Email protected] ~]# ln-s/usr/local/mysql/bin/mysql/usr/bin
This completes the soft link.
Here are the additions:
Under Linux, in the case of MySQL normal operation, enter MySQL prompt: MySQL command not found
Encounter-bash:mysql:command not found situation, this is because the/usr/local/bin directory is missing MySQL, only need a way to establish a soft link, that can be resolved:
Map the MySQL installation directory, such as Mysqlpath/bin/mysql, to the/usr/local/bin directory:
# cd/usr/local/bin # ln-fs/mysqlpath/bin/mysql MySQL
There are other commonly used commands such as mysqladmin, mysqldump, etc. can be resolved by this method when not available.
Note: Where Mysqlpath is the actual installation path of MySQL
Ps:linux View MySQL installation path
First, view the file installation path
Since there is more than one place to install the software, all the paths (addresses) that are first said to view the file installation.
Take MySQL for example here. For example, I installed MySQL, but do not know where the files are installed, in which folders, you can use the following command to view all the file path in the terminal input:
[[Email protected] ~] #whereis MySQL
Enter, if you installed MySQL, will show the file installation address, such as my display (the installation address may be different)
[[Email protected] ~] #whereis MySQL
MySQL:/usr/bin/mysql/usr/lib/mysql/usr/share/mysql/usr/share/man/man1/mysql.1.gz
Second, the path of the query running file (folder address)
If you just query the file's running file address, you can use the following command (or MySQL, for example):
which MySQL
Terminal display:
[email protected] ~]# which mysql/usr/bin/mysql
Methods for solving Bash:mysql:command not found