切换到root用户,然后进入mysql 的bin目录后,
root@cps-desktop:/usr/local/mysql/bin# /etc/init.d/mysql stop
root@cps-desktop:/usr/local/mysql/bin# ./mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
root@cps-desktop:/usr/local/mysql/bin# ./mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
最后重启数据库:
root@cps-desktop:/usr/local/mysql/bin# /etc/init.d/mysql restart
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql>
set password=password('');
创建 MYSQL 本地用户
grant all privileges on *.* to 'admin'@'%'identified by 'admin' with grant option;
grant all privileges on *.* to 'admin'@localhost identified by 'admin' with grant option;
flush privileges;