Linux上安装好Mysql,只能通过安装路径/bin/mysql -uroot -p方式进行登录
别的路径下mysql -uroot -p尝试登录数据库
系统提示:-bash: mysql: command not found
或提示-bash: /usr/bin/mysql: No such file or directory
原因是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,会找不到命令,需要映射一个链接到/usr/bin目录下,相当于建立一个链接文件。
找到mysql命令或mysqladmin命令的完整路径,我的mysql的路径是:/usr/local/mysql/bin/mysql,执行以下命令:ln -s /usr/local/mysql/bin/mysql /usr/bin/
[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.63 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
可以在Linux的任何路径下进行MySQL的登录