下载:https://dev.mysql.com/downloads/mysql/
1、安装
解压zip到安装目录C:\mysql-8.0.13-winx64
在安装目录下新建配置文件my.ini,内容如下:
[mysqld] # 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 = 128M # 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 = C:\mysql-8.0.13-winx64 datadir = C:\mysql-8.0.13-winx64\mysqldata port = 3306 # server_id = ..... # 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 character-set-server = utf8mb4 performance_schema_max_table_instances = 600 table_definition_cache = 400 table_open_cache = 256 [mysql] default-character-set = utf8mb4 [client] default-character-set = utf8mb4
注意:
basedir = C:\mysql-8.0.13-winx64 安装目录
datadir = C:\mysql-8.0.13-winx64\mysqldata 数据库文件目录
根据自己实际情况配置。
2、数据库初始化
已管理员运行命令行在数据库安装目录下的bin目录中执行如下命令:
mysqld --initialize --console
执行完成之后会打印出root密码,记下来,后面修改密码需要用到。
3、安装服务
在bin下执行命令:
mysqld --install mysql
后面的mysql为服务名,可以不写,默认mysql
安装成功之后,执行命令:
net start mysql
就可以启动mysql服务了。
4、修改密码
在bin下执行命令,登录mysql
mysql -u root -p
然后输入上面日志中的密码,即可登录。如果想要创建数据库则需要修改默认密码,执行下面的命令:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';