安装
1.下载安装包
2.解压包
3.文件夹内创建my.ini配置文件,并添加内容
# 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] # 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. # 设置mysql的安装目录 basedir = D:\\MySQL\\mysql1 # 设置mysql数据库的数据的存放目录 datadir = D:\\MySQL\\mysql1\\data # 设置3306端口 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 # 允许最大连接数 max_connections = 200 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors = 10 # 服务端使用的字符集默认为UTF8 character-set-server = utf8mb4 # 创建新表时将使用的默认存储引擎 default-storage-engine = INNODB [mysql] # 设置mysql客户端默认字符集 default-character-set = utf8mb4 [client] # 设置mysql客户端连接服务端时默认使用的端口 port=3306 default-character-set = utf8mb4
4.使用cmd管理员模式进入mysql的bin目录下
cd D:\MySQL\mysql1\bin
5.执行数据库初始化
mysqld --initialize --console
@localhost:密码
这个密码一定要记住
6.运行安装服务
mysqld.exe -install
如果需要改服务名的话
mysqld.exe -install MySQL2
7.运行
net start mysql
但是目前只能通过localhost也就是本机登录
继续cmd管理员模式进入安装目录的bin文件下
登录mysql
mysql -u root -p
输入刚刚保存的密码(这里只能手打不能粘贴)
此时已进入到mysql里面
选择数据库
use mysql
更改user表中的host,把localhost改为%
update user set host='%' where user='root';
刷新权限
flush privileges;
修改mysql登录密码(需要先登录)
alter user'root'@'localhost' identified with mysql_native_password by '你的密码';
mysql -u root -p