Tag Archives: mysql: command not found

When installing MySQL database on MAC, the system prompts MySQL: command not found

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

After we install mysql, we enter the MySQL command in the terminal and find that we can’t see the database we installed. This is because you don’t configure the environment variables

Install MySQL database in OS system and save it in/usr/local/MySQL by default

So how do we configure environment variables

1. Open terminal, enter: sudo Su enter to enter the system administrator management directory (of course, you need to enter your user password to enter)

2. Enter the command: VIM/etc/profile, and then enter the VIM editing interface

3. In the VIM editing interface, press I to enter the editing state. Then, you can add the path name and enter the command: export path = $path/usr/local/MySQL/bin

4. Press the ESC key to exit the editing state

5. Enter the command: WQ( Indicates save and force exit)

6. Then I’ll call back to my previous terminal interface

7. Then enter the command: source/etc/profile in this interface to indicate that the settings will take effect immediately. Of course, it’s the same for you to restart after closing

At this time, you can enter: MySQL — version enter to test

What if the system still prompts MySQL: command not found

1. Apple – > System Preferences – > At the bottom, click Mysql to close the MySQL service in the pop-up page

2. Enter the terminal input: CD/usr/local/MySQL/bin

3. After entering, log in the administrator permission sudo Su (enter your computer password)

4. Enter the following command to disable the MySQL verification function./mysqld_ safe –skip-grant-tables & ( Note that mysqld

5. After entering, MySQL will restart automatically (you can see in the preferences that the state of MySQL will change to running)

6. Then enter the command./MySQL

7. After entering, you can see the following effect:

The comfortable MySQL > Prompt

8. Here’s how to change the password

Then enter: flush priorities

After entering, enter: set password for ‘root’ @’localhost ‘= password (‘123’)

9. Re open a terminal and enter: MySQL – uroot – P123 to enter MySQL data:

When installing MySQL database on Mac OS, the system prompts MySQL: command not found

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

After we install mysql, we enter the MySQL command in the terminal and find that we can’t see the database we installed. This is because you don’t configure the environment variables

Install MySQL database in OS system and save it in/usr/local/MySQL by default

So how do we configure environment variables

1. Open terminal, enter: sudo Su enter to enter the system administrator management directory (of course, you need to enter your user password to enter)

2. Enter the command: VIM/etc/profile, and then enter the VIM editing interface

3. In the VIM editing interface, press I to enter the editing state. Then, you can add the path name and enter the command: export path = $path/usr/local/MySQL/bin

4. Press the ESC key to exit the editing state

5. Enter the command: WQ( Indicates save and force exit)

6. Then I’ll call back to my previous terminal interface

7. Then enter the command: source/etc/profile in this interface to indicate that the settings will take effect immediately. Of course, it’s the same for you to restart after closing

At this time, you can enter: MySQL carriage return to test

What if the system still prompts MySQL: command not found

1. Apple – > System Preferences – > At the bottom, click Mysql to close the MySQL service in the pop-up page

2. Enter the terminal input: CD/usr/local/MySQL/bin

3. After entering, log in the administrator permission sudo Su (enter your computer password)

4. Enter the following command to disable the MySQL verification function./mysqld_ safe –skip-grant-tables & ( Note that mysqld

5. After entering, MySQL will restart automatically (you can see in the preferences that the state of MySQL will change to running)

6. Then enter the command./MySQL

7. After entering, you can see the following effect:

The comfortable MySQL > Prompt

8. Here’s how to change the password

Then enter: flush priorities

After entering, enter: set password for ‘root’ @’localhost ‘= password (‘123’)

9. Re open a terminal and enter: MySQL – uroot – P123 to enter MySQL data:

Reference: https://blog.csdn.net/adley_ app/article/details/54694230

[troubleshooting] through the remote execution of the script by the scheduling system, the MySQL command not found exception is reported

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Today, when the company uses LS scheduling system (Baidu’s internal tool) to execute remote scripts, it fails every time

The content of the script is relatively simple. In fact, it is to insert the data in HDFS (AFS) into Palo (doris) database. The script is as follows:

mysql -h xxx -P 9030 -uxxx -p'xxx' -e "LOAD LABEL baijiahao.bjh_spider_view_count_${day}_${label_time} (DATA INFILE('afs://xxx/user/feed-bjh/database/spider_view_count_showx/${day}/*') INTO TABLE bjh_spider_view_count) PROPERTIES('cluster'='feed_bjh','timeout'='86400','max_filter_ratio'='0.0001')"

At first, I thought it was my script problem. I have been testing this script on the remote development machine and found that it can be executed correctly, but it will fail through the scheduling system

At first, I didn’t pay attention to the error log. Suddenly, I saw that the error in the log was:

mysql command not found

There is no problem for me to test the MySQL instruction on the development machine

After searching for information, I found that the reason for this problem is that my MySQL is installed in the data partition I set, not in the default/usr/bin/MySQL. When SSH executes commands remotely, it reads from/usr/bin, so it can’t be found

Through which mysql, I found that my MySQL path is:

alias mysql='/home/work/opt/mysql/mysql-5.6.38/bin/mysql'
    ~/opt/mysql/mysql-5.6.38/bin/mysql

Now there are two solutions:

(1) Write the full name of MySQL in the script

/home/work/opt/mysql/mysql-5.6.38/bin/mysql -h xxx -P 9030 -uxxx -p'xxx' -e "LOAD LABEL baijiahao.bjh_spider_view_count_${day}_${label_time} (DATA INFILE('afs://xxx/user/feed-bjh/database/spider_view_count_showx/${day}/*') INTO TABLE bjh_spider_view_count) PROPERTIES('cluster'='feed_bjh','timeout'='86400','max_filter_ratio'='0.0001')"

(2) To establish a soft connection, you need root permission

ln -s /home/work/opt/mysql/mysql-5.6.38/bin/mysql /usr/bin/mysql

Reference

https://blog.csdn.net/qq1124794084/article/details/77529889

MySQL Error: the solution of command not found

When building zrlog under Tomcat architecture, MySQL will report an error. As follows:

When entering the MySQL command

Error report

# mysql: command not found
   This command does not exist

When restarting MySQL service

# /etc/init.d/mysqld restart

Error report

# mysqld_safe A mysqld process already exists

Try

First # PS aux | grep grep , and then # kill - 9 PID , kill MySQL related processes, no, report an error

First # kill MySQL , and then restart, or not, report an error

Modify the/etc/my.cnf file, clear the relevant rules, restart mysql, or not

Solution:

MySQL is clearly installed and running normally. How can this problem occur

Method 1 (palliative treatment)

Run the command as an absolute path. For example, my native path is /usr/local/MySQL/bin/MySQL

# /usr/local/mysql/bin/mysql restart

Method 2 (cure the root cause)

# ln -s /usr/local/mysql/bin/mysql /usr/bin

It is equivalent to creating a linked file- S for soft link

# mysql -uroot -p