After we have installed MySQL, enter the MySQL command at the terminal and find that we cannot see the database you installed because you do not have the environment variable configured.
installing MySQL database in OS system is saved by default in/usr/local/mysql
So how do we configure environment variables?
1, open terminal, enter: sudo su enter into the System Administrator management directory (of course you need to enter your user password to enter)
2. Input command:Vim/etc/profile then go to the vim editing interface
3, in the Vim editing interface, press I to enter the editing state, then, you can add the path name, enter the command: Export path= $PATH:/usr/local/mysql/bin
4. Press the ESC key to exit the edit state
5. Input command:: wq! (Means save and force exit)
6, then recalled my previous terminal interface:
7, in this interface and then enter the command: Source/etc/profile indicates that the setting takes effect immediately, of course, you shut down after the restart is the same reason
You can enter: MySQL return to test
What if the system still prompts Mysql:command not found?
1, Apple-and system preferences, the bottom point of MySQL in the pop-up page to close the MySQL service;
2. Enter Terminal input: Cd/usr/local/mysql/bin
3, enter after the login administrator permissions sudo su (input your computer password)
4, enter the following command to disable the MySQL authentication function./mysqld_safe--skip-grant-tables & (Note mysqld)
5. mysql will restart automatically after carriage return (you can see that the MySQL status will become running in the preferences)
6. Then enter the command./mysql
7, enter after you can see the following effect:
There is a comfortable mysql> prompt!!!
8, the following is the change password
Then enter:FLUSH privileges;
after entering the carriage, enter: SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' 123 ');
9. Re-open a terminal and enter: the mysql-uroot-p123 can enter MySQL data:
Ref: 54694230
Mac os install MySQL database, the system prompts Mysql:command not found what to do