windows下mysql解压版安装及centos下mysql root密码忘记

windows安装

1. 下载zip版的解压后将bin添加到path.

2. 修改解压目录D:mysqlmysql-5.7.12-winx64下的my.ini,设置路径:

还要添加

[client]
default-character-set=utf8

在[mysqld]下添加

character-set-server=utf8

设置编码

3.以管理员身份打开命令行,cd到bin目录下,依次执行下面三个命令:

mysqld -install

mysqld --initialize

net start mysql

4. mysql -u root -p登录时,需要输入密码,否:

密码在哪设定的呢?

在安装目录下查找后缀为.err的文件,打开后可以看到这么一行:

一个临时的随机密码

centos下忘记root密码

刚租的阿里云ecs,不知道里面自带的mysql的密码,解决步骤如下

1. vi /etc/my.cnf

添加一句 skip-grant-tables

2. service mysqld restart

3.无密码登录修改root密码

mysql -uroot -p

use mysql;  

update user set authentication_string=password('*****') where user='root';

flush privileges;

exit

4. 恢复/etc/my.cnf

原文地址:https://www.cnblogs.com/redips-l/p/7273439.html