本文共 2529 字,大约阅读时间需要 8 分钟。
使用解压缩版的mysql
配置
MYSQL_HOME=E:\mysql-5.7.18-winx64
添加PATH:
Path=%MYSQL_HOME%\bin
里面的内容如下:(要更换其中的basedir
和datadir
)
[client] no-beep # pipe # socket=mysql port=3306 [mysql] default-character-set=utf8 # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] explicit_defaults_for_timestamp = TRUE # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 2G # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir="E:\mysql-5.7.18-winx64\" datadir="F:\mysql_data\" port=3306 server_id=1 general-log=0 general_log_file="mysql_general.log" slow-query-log=1 slow_query_log_file="mysql_slow_query.log" long_query_time=10 log-error="mysql_error_log.err" default-storage-engine=INNODB max_connections=1024 query_cache_size=128M key_buffer_size=128M innodb_flush_log_at_trx_commit=1 innodb_thread_concurrency=128 innodb_autoextend_increment=128M tmp_table_size=128M # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" character-set-server=utf8 innodb_flush_method=normal
打开命令提示符以管理员身份运行,cd到E:\mysql-5.7.18-winx64\bin下
安装MySQL(其中的MySQL是安装服务器的名称,可以指定任何名称)
mysqld --install MySQL --defaults-file="E:\mysql-5.7.18-winx64\my.ini"
如果出现
The service already exists! The current server installed: E:\mysql-5.7.18-winx64\bin\mysqld MySQL
则移除原先的服务: mysqld -remove MySQL
并且清除data目录下的所有数据
安装成功后会在系统的服务组策中添加该服务,在使用时只需要开启即可。
mysqld --initialize-insecure --user=root(任意的用户名)
net start mysql
值得注意的是用命令安装的MySQL在Windows系统下默认服务名为mysql,默认密码为空。
mysql -u root -p
显示mysql>
表示进入MySQL
转载地址:http://zokvb.baihongyu.com/