Directly say the process:
1. Download MySQL 5.7 Latest version from MySQL website: There are two kinds of DMG's fool's bag, one is tar.gz's compression package. I downloaded the tar.gz zip package.
2. After the successful download, the first trial command sudo tar zxvf extracted to the current directory, because the default is in/user/fan/downloads, after decompression moved to/user/local
The directory has not been found because it has just come into contact with Apple. It turns out that Apple's table key automatically defaults to the first/users, not/user
In the current directory/users/fan/downloads use command: sudo mv +mysql folder/usr/local/mysql (mysql path does not exist, sudo mkdir /usr/local/mysql create first.) )
3. After moving past
- # Move the unpacked binary package to the installation directory
- sudo mv mysql-5.7.20-macos10.12-x86_64
/usr/local/mysql
- # change the MySQL installation directory to the user and user group
- Cd/usr/local
- sudo chown-r root:wheel MySQL
- # perform some default initialization (create default configuration file, authorization table, etc.) by executing the mysql_install_db script in the scripts directory
- Cd/usr/local/mysql
-
sudo bin/mysqld--initialize--user=mysql
5.7. 6 The above version cancels the scripts directory, the init command changed to sudo bin/mysqld--initialize--user=mysql
?? : When initializing, MySQL Initializes a password that cannot be forgotten or will not be logged in.
# Move the unpacked binary package to the installation directory sudo mv mysql-5.6.24-osx10.9-x86_64/usr/local/mysql# change the MySQL installation directory to the user and user group cd/usr/Localsudo Chown-R root:wheel mysql# perform some default initialization (create default configuration file, authorization table, etc.) by executing mysql_install_db script in scripts directory cd/usr/local/Mysqlsudo scripts/mysql_install_db--user=MySQL
Attention:?? There is a problem: When you start MySQL, the startup is not successful, because the MySQL startup program Support-files/mysql.server directory defaults to the/usr/local/mysql directory, not its subordinate directory. I was putting
mysql-5.6.24-osx10.9-x86_64 files in the file and files see all moved to the/usr/local/mysql/directory, after the successful start.
4. Installation complete, test start, restart and stop:
- Cd/usr/local/mysql
- # start
- sudo support-files/mysql.server start
- # restart
- sudo support-files/mysql.server restart
- # stop
- sudo support-files/mysql.server stop
- # Check MySQL run status
- sudo support-files/mysql.server status
5. After successful launch
Use the password you just initialized to get to MySQL.
Enter the/usr/local/mysql/bin directory
Mysql-uroot-p
Prompt to enter a password, copy the password just now. Successfully entered.
Then you can change the password: The command is as follows
Step 1:set PASSWORD = PASSWORD (' Your new PASSWORD ');
Step 2:alter USER ' root ' @ ' localhost ' PASSWORD EXPIRE never;
Step 3:flush privileges;
It must be like this three-part. I'll be fine later.
or according to the following two articles: (the first installment, the second is to set the MySQL password and login)
Source:
Http://www.widlabs.com/article/mac-os-x-install-mysql-with-tar-gz
http://blog.csdn.net/u013205165/article/details/52264311
Installing MySQL under Apple and the problems encountered