一、运行mysql -uroot -p命令报错:

[root@localhost ~]# mysql -uroot -p
-bash: mysql: command not found

解决,给mysql配置环境变量:

[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin

[root@localhost ~]# source /etc/profile

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.33 Source distribution

Copyright (c) 2000, 2016, 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>
mysql设置环境变量截图操作步骤如下:

在这里插入图片描述
2.
在这里插入图片描述
3.
在这里插入图片描述
4.
在这里插入图片描述
5.
在这里插入图片描述

二、运行php -v命令报错:

[root@localhost ~]# php -v
-bash: php: command not found

解决方法:

[root@localhost ~]# vim /etc/profile #在配置文件最后面添加如下一行配置
export PATH=$PATH:/usr/local/php/bin

[root@localhost ~]# source /etc/profile

[root@localhost ~]# php -v
PHP 7.4.0 (cli) (built: Jun 19 2023 11:33:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v12.0.5, Copyright (c) 2002-2022, by ionCube Ltd.
php设置环境变量截图操作步骤:

在这里插入图片描述
2.
在这里插入图片描述
3.
在这里插入图片描述
4.
在这里插入图片描述

tips:
报错是因为没有找到路径,敲完完整路径就不会报错,就是路径有点长,敲起来麻烦,所以添加环境变量,方便:
完整路径:/usr/local/mysql/bin/mysql -uroot -p
完整路径:/usr/local/php/bin/php -v

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐