mysql official provides a way to install mysql with the interface, I do not want to use. Since the mac is also a unix system, then, with the idea that a unix installation is also accepted. However, I do not want to install it in / usr / local / mysql, I think the computer is mine, and I want to install it where I installed where, after all, mysqld is not just a program.
The following record my real operating completely green install mysql server. And so one day, I do not want it, I can delete their own definition, you do not have hard to find this directory, which links to find.
1: determining program directory:
file decompressed "mysql-5.7.28-macos10.14-x86_64 " into "/ Users / huGuohua / Applications"; and
2: set home directory
MYSQL_HOME = / Users / huGuohua /Applications/mysql-5.7.28-macos10.14-x86_64
3: create a data directory in your home directory and configuration files and directory service log directory
mkdir -p data log
a put data file, put a log file
4: in the main directory my.cnf file and create mysql.sock
5: edit the my.cnf file
as follows:
the contents of this reference content phpstudy in the my.ini.
[ MySQL ] default-Character-SET = UTF8 [ mysqld ] Port = 3306 port corresponding to the server #Mysql; the basedir = / the Users / huGuohua / the Applications / MySQL-5.7.28-macos10.14 -x86_64 #Mysql installation absolute path; DATADIR = / the Users / huGuohua / the Applications / MySQL-5.7.28-macos10.14 -x86_64 / data / #Mysql data stored absolute path; Socket = /Users/huGuohua/Applications/mysql-5.7.28-macos10.14 - x86_64 mysql.sock /: # socket file PLUGIN_DIR = /Users/huGuohua/Applications/mysql-5.7.28-macos10.14 path -x86_64 / lib / plugin #mysql plug located in plugin; log-error = / the Users /huGuohua/Applications/mysql-5.7.28-macos10.14-x86_64/log/error.log #mysql生成的错误日志存放的路径 character-set-server=utf8 default-storage-engine=MyIsam max_connections=100 collation-server=utf8_unicode_ci init_connect='SET NAMES utf8' innodb_buffer_pool_size=64M innodb_flush_log_at_trx_commit=1 innodb_lock_wait_timeout=120 innodb_log_buffer_size=4M innodb_log_file_size=256M interactive_timeout=120 join_buffer_size=2M key_buffer_size=32M log_error_verbosity=1 max_allowed_packet=16M max_heap_table_size=64M myisam_max_sort_file_size=64G myisam_sort_buffer_size=32M read_buffer_size=512kb read_rnd_buffer_size=4M server_id=1 skip-external-locking=on sort_buffer_size=256kb table_open_cache=256 thread_cache_size=16 tmp_table_size=64M wait_timeout=120 [client] default-character-set=utf8
Database Initialization:
$ MYSQL_HOME is} {/ bin / mysqld --initialize MYSQL_HOME is --datadir = $ {} / Data --log-error = $ {} MYSQL_HOME is /log/error.log --explicit-Defaults-for-timestamp = oN
run database services:
nohup MYSQL_HOME $ {} / bin / mysqld --defaults-File = $ {} /my.cnf & MYSQL_HOME
normal circumstances, we run ps -ef | grep mysqld, you can see the database service started.
Change the root password
in $ {MYSQL_HOME} /log/error.log found in the root password, and then use the client tools to log, when the first login, the user will be prompted to change the root password.
Stop database service:
$ MYSQL_HOME is} {/ bin / mysqladmin -uroot--p "123456" -h127.0.0.1 -P3306 the shutdown
interface prompts the
mysqladmin: [Warning] A password ON the Using The Command Line interface CAN BE in the insecure.
[20 is -01-01 22:21:40 /Users/huGuohua/Applications/mysql-5.7.28-macos10.14-x86_64]$
[1] + done nohup $ { MYSQL_HOME} / bin / mysqld --defaults-file = $ {MYSQL_HOME} /my.cnf
another method of starting the mysql
manner that corresponds to the content profile using the command parameters to the free Specifies
nohup $ {MYSQL_HOME} / bin / mysqld --defaults-file = $ {MYSQL_HOME} /my.cnf --basedir = $ {MYSQL_HOME} --datadir = $ {MYSQL_HOME} / data --plugin-dir = $ { MYSQL_HOME} / lib / plugin --log- error = $ {MYSQL_HOME} /log/error.log --pid-file = / $ {MYSQL_HOME} /mysql.pid --socket = $ {MYSQL_HOME} /mysql.sock - -port = 3306 &