直接运行mysql和php命令提示未找到命令的报错,如:-bash: mysql: command not found ---解决办法-- CentOS下给mysql、php配置环境变量

14 篇文章 1 订阅
6 篇文章 1 订阅

一、运行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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值