1.环境变量配置
右键计算机–属性–高级系统设置–环境变量,在系统变量中找到Path编辑,在结尾处追加你的mysql的bin文件夹地址D:\Program Files\mysql-8.0.12-winx64\bin
2.创建my.ini文件
[client]
# pipe=
socket=MYSQL
port=3306
[mysql]
no-beep
# default-character-set=
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
# server_type=3
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory
# shared-memory-base-name=MYSQL
# The Pipe the MySQL Server will use
# socket=MYSQL
# The TCP/IP Port the MySQL Server will listen on
port=3306
# Path to installation directory. All paths are usually resolved relative to this.
basedir=D:\Program Files\mysql-8.0.12-winx64
# Path to the database root
datadir=D:\Program Files\mysql-8.0.12-winx64\data
# The default character set that will be used when a new schema or table is
# created and no character set is defined
# character-set-server=
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
# Set the SQL mode to strict
sql-mode=
3.配置MySQL服务
a) 用管理员身份打开cmd,进入mysql的bin文件夹。(注意要用管理员打开,否则权限不足)
b)执行:mysqld -install,显示:Service successfully installed. 则注册服务成功。如果要删除服务:mysqld -remove c)MySQL数据库在升级到5.7版本后,和之前的版本有些不一样,没有data文件夹,MySQL数据库文件是保存在data文件夹中的,标准的修改方法是,打开cmd命令窗口,并且进入到MySQL安装目录中的bin目录,然后输入如下命令初始化数据:mysqld –initialize-insecure 。执行完上面命令后,MySQL会自建一个data文件夹,并且建好默认数据库,登录的用户名为root,密码为空。
d)安装成功后就要启动服务了,继续在cmd中输入net start mysql,停止服务net stop mysql。
如果失败查看错误日志,D:\Program Files\mysql-8.0.12-winx64\data下*.err日志
4 登陆mysql服务,修改密码
a)继续在cmd中输入:mysql -u root 回车,密码为空,继续回车,连接上mysql。
b)屏蔽权限:mysqld --skip-grant-tables.flush privileges;
c)8.0版本以上: alter user ‘root‘@‘localhost‘IDENTIFIED BY ‘123‘;注:mysql8.0以上密码策略限制必须要大小写加数字特殊符号,我没碰到,修改失败的话注意一下
8.0版本以下:set password for [email protected] =password(‘root‘);
d)FLUSH PRIVILEGES;
原文地址:https://www.cnblogs.com/god-monk/p/9759023.html