一、在linux中已經安裝好mysql,經過#ps -ef |grep mysql 能顯示mysql已經啓動,但去進入mysql命令頁面出現以下問題:mysql
1 [root@root ~]# mysql u -p 2 -bash: mysql: command not found
查找mysql是否已經啓動linux
1 [root@root ~]# ps -ef | grep mysql 2 root 1172 1 0 18:28 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/service/mysql --pid-file=/service/mysql/root.pid 3 mysql 1285 1172 9 18:28 ? 00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/service/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/service/mysql/root.err --pid-file=/service/mysql/root.pid 4 root 1440 1288 0 18:28 pts/1 00:00:00 grep mysql
緣由:這是因爲系統默認會查找/usr/bin下的命令,若是這個命令不在這個目錄下,固然會找不到命令,咱們須要作的就是映射一個連接到/usr/bin目錄下,至關於創建一個連接文件。
首先得知道mysql命令或mysqladmin命令的完整路徑,好比mysql的路徑是:/usr/local/mysql/bin/mysql,【此路經是mysql實際安裝路徑】咱們則能夠這樣執行命令 sql
1 [root@root bin]# ln -fs /usr/local/mysql/bin/mysql /usr/bin/
1 [root@root bin]# mysql -u -p 2 Welcome to the MySQL monitor. Commands end with ; or \g. 3 Your MySQL connection id is 1 4 Server version: 5.6.20 Source distribution 5 6 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 7 8 Oracle is a registered trademark of Oracle Corporation and/or its 9 affiliates. Other names may be trademarks of their respective 10 owners. 11 12 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 13 14 mysql> Ctrl-C -- exit! 15 Aborted