下载mysql
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-win32.zip
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-winx64.zip
解压到D:\mysql-5.7.12-winx64
设置set path=%path%;D:\mysql-5.7.12-winx64\bin;
新建my.ini 复制my-defualt.ini内容
加入:
basedir=D:\mysql-5.7.12-winx64
datadir=D:\mysql-5.7.12-winx64\data
port = 3306
管理员权限进入D:\mysql-5.7.12-winx64\bin
mysqld --initialize --user=mysql --console
此处会生成一个随机密码
mysql -uroot -p
A temporary password is generated for root@localhost: ?ed&Dd9j#r1O
安装mysql服务,默认名为mysql
mysqld -install [server name]
启动mysql
net start mysql
登陆
mysql -u[user] -p [password]
mysql -uroot -p ?ed&Dd9j#r1O
修改密码
首先停止服务net stop mysql
mysqld --skip-grant-tables
另起一个admin cmd窗口,在bin目录下执行
mysql -uroot -p
show databases;
use mysql;
update mysql.user set authentication_string=password('new_password') where user='root' and Host = 'localhost';
flush privileges;
quit;
mysql -uroot -p 登录
[ERROR]You must reset your password using ALTER USER statement before executing this statement.
set password =password('new password');
alter user 'root'@'localhost' password expire never;
flush privileges;
exit;
重新登录
useradd -r -g mysql mysql
chown -R mysql .
chown -R mysql .
#添加自启动
chkconfig --add mysql
chkconfig --level 2345 mysql on