安装好MySQL后,用SQL去修改root帐号的密码,结果不能登录了!

取得MySQL Community Edtion 5.0.22版本的zip package,解压缩到 D:\MySQL,然后在另外一个分区建立
了数据目录I:\MyData,把D:\MySQL\data里面的内容复制了一份放到I:\MyData下面。做好这个步骤后,要准
备修改MySQL的配置文件和安装Windows Service了。

配置文件中需要新增的内容:
# The following options will be passed to all MySQL clients
[client]
# Add by Shark Wang
default-character-set = utf8

# The MySQL server
[mysqld]
# Add by Shark Wang
basedir = D:/MySQL/
datadir = I:/MyData/
default-character-set = utf8
default-collation = utf8_general_ci

然后启用InnoDB,需要把下面的内容启用,去掉前面的注释符:
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = I:/MyData/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = I:/MyData/
innodb_log_arch_dir = I:/MyData/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

然后在DOS命令行执行安装Service的命令:
D:\MySQL\bin\mysql-max-nt.exe --install MySQL --defaults-file=D:/MySQL/conf/my.ini

这样就可以启动MySQL Service了!

最后剩下的就是更改MySQL的root帐号的密码,用mysql登录后,执行:
SELECT mysql;
UPDATE user SET password='xxxxxx' WHERE user='root';
FLUSH PRIVILEGES;

重新登录,系统说root密码错误!!!火星了... - -|||

请教了一下汪总,原来这个地方有一个错误,正确的方法如下:
UPDATE user SET password=password('xxxxxx') WHERE user='root';

你可能感兴趣的:(sql,mysql,windows,SQL Server,dos)