Mac System Source Code Compilation Installation MySQL 5.7. 17 Tutorial

  • 2021-07-18 09:15:09
  • OfStack

1. Download and unzip to:/Users/xiechunping/Softwares/mysql-5. 7.17

Download address: http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5. 7/mysql-boost-5. 7.17. tar.gz

2. Enter mysql-5. 7.17 and execute cmake


cd ../mysql-5.7.17
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=_mysql -DMYSQL_TCP_PORT=3306 -DMYSQL_DATADIR=/usr/local/mysql/db_data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/Users/xiechunping/Softwares/mysql-5.7.17/boost

3. Configure data directory permissions


chown -R _mysql:_mysql /usr/local/mysql/db_data

4. Compile and install


make&&make install

5. Install the database and start


cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/db_data
support-files/mysql.server start

6. Modify the database root user password (the first entry password is empty)

Modification:/usr/local/mysql/support-files/mysql. server Line 280

Add startup options for mysql: --user=mysql--skip-grant-tables-skip-networking

Execution:


support-files/mysql.server stop && support-files/mysql.server stop
bin/mysql -u root mysql
mysql>UPDATE user SET authentication_string=PASSWORD('mysql54321') where USER='root';
mysql>FLUSH PRIVILEGES;
mysql>quit;

support-files/mysql.server stop

Restore/usr/local/mysql/support-files/mysql. server


support-files/mysql.server start

bin/mysql -uroot -p
Enter password: < Enter the new password mysql54321>
mysql>SET PASSWORD = PASSWORD('mysql54321');
mysql>ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
mysql>flush privileges;
mysql>quit;

Related articles: