关于mysql每次开启都需要source ~/.bash_profile 【unix】

本文介绍了一种常见的问题,即在使用ZSH作为默认Shell时,尝试运行MySQL命令却遇到“command not found”错误的情况。文章详细解释了问题的原因,并提供了解决方案,包括修改~/.zshrc文件来加载~/.bash_profile中的环境变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天刚刚装了mysql,使用的是安装包方式安装,安装方法参考 https://www.jianshu.com/p/fd3aae701db9

然而,在那装完之后,输入````mysql -uroot -p``` 却显示 command not found

目前的解决方法:每次重启终端的时候,首先输入 source ~/.bash_profile (前提是你已经按照以上提供的链接在环境文件内添加了环境变量)

于是再输入 mysql -uroot -p 就能进入mysql


------------------------------------------------------------------------------------

经过一番搜查发现了原因

应该是我的终端使用了zsh进行改造,所以好像启动终端后会从zsh的shell上启动,于是在.bash_profile的命令没有被执行

解决方法:vim ~/.zshrc

添加命令 source ~/.bash_profile

保存退出

这样每次从Item2启动终端就会先执行 source ~/.bash_profile ,这样就可以直接访问mysql

/usr/bin/cmake -S/home/zbt/S/sylar -B/home/zbt/S/sylar --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /home/zbt/S/sylar/CMakeFiles /home/zbt/S/sylar/CMakeFiles/progress.marks make -f CMakeFiles/Makefile2 all make[1]: Entering directory '/home/zbt/S/sylar' make -f CMakeFiles/sylar.dir/build.make CMakeFiles/sylar.dir/depend make -f CMakeFiles/test_module.dir/build.make CMakeFiles/test_module.dir/depend make[2]: Entering directory '/home/zbt/S/sylar' cd /home/zbt/S/sylar && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/zbt/S/sylar /home/zbt/S/sylar /home/zbt/S/sylar /home/zbt/S/sylar /home/zbt/S/sylar/CMakeFiles/test_module.dir/DependInfo.cmake --color= make[2]: Entering directory '/home/zbt/S/sylar' [ 1%] Generating sylar/http/httpclient_parser.rl.cc [ 1%] Generating sylar/http/http11_parser.rl.cc make[2]: Leaving directory '/home/zbt/S/sylar' make -f CMakeFiles/test_module.dir/build.make CMakeFiles/test_module.dir/build cd /home/zbt/S/sylar/sylar/http cd /home/zbt/S/sylar/sylar/http ragel /home/zbt/S/sylar/sylar/http/http11_parser.rl -o /home/zbt/S/sylar/sylar/http/http11_parser.rl.cc -l -C -G2 --error-format=msvc make[2]: Entering directory '/home/zbt/S/sylar' make[2]: ragel: Command not found ragel /home/zbt/S/sylar/sylar/http/httpclient_parser.rl -o /home/zbt/S/sylar/sylar/http/httpclient_parser.rl.cc -l -C -G2 --error-format=msvc make[2]: ragel: Command not found make[2]: *** [CMakeFiles/sylar.dir/build.make:66: sylar/http/http11_parser.rl.cc] Error 127 make[2]: *** Waiting for unfinished jobs.... make[2]: *** [CMakeFiles/sylar.dir/build.make:71: sylar/http/httpclient_parser.rl.cc] Error 127 [ 1%] Generating sylar/uri.rl.cc [ 1%] Building CXX object CMakeFiles/test_module.dir/tests/test_module.cc.o cd /home/zbt/S/sylar/sylar /usr/bin/c++ -DDBUG_OFF -Dtest_module_EXPORTS -I/home/zbt/S/sylar/. -I/apps/sylar/include -I/usr/include/mysql -rdynamic -O3 -fPIC -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations -fPIC -o CMakeFiles/test_module.dir/tests/test_module.cc.o -c /home/zbt/S/sylar/tests/test_module.cc ragel /home/zbt/S/sylar/sylar/uri.rl -o /home/zbt/S/sylar/sylar/uri.rl.cc -l -C -G2 --error-format=msvc make[2]: ragel: Command not found make[2]: *** [CMakeFiles/sylar.dir/build.make:76: sylar/uri.rl.cc] Error 127 make[2]: Leaving directory '/home/zbt/S/sylar' make[1]: *** [CMakeFiles/Makefile2:247: CMakeFiles/sylar.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 1%] Linking CXX shared library lib/libtest_module.so /usr/bin/cmake -E cmake_link_script CMakeFiles/test_module.dir/link.txt --verbose=1 /usr/bin/c++ -fPIC -rdynamic -O3 -fPIC -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations -shared -Wl,-soname,libtest_module.so -o lib/libtest_module.so CMakeFiles/test_module.dir/tests/test_module.cc.o -L/apps/sylar/lib -L/apps/sylar/lib64 make[2]: Leaving directory '/home/zbt/S/sylar' [ 1%] Built target test_module make[1]: Leaving directory '/home/zbt/S/sylar' make: *** [Makefile:87: all] Error 2
最新发布
07-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值