mysql-community-server安装完后不知道root密码
修改方法:
service mysqld stop mysqld_safe --skip-grant-tables & mysql -u root use mysql; update user set authentication_string=password('1111') where user='root'; flush privileges; quit service mysqld restart
或者用 /etc/init.d/mysql start启动
启动后用命令建数据库是还是会提示需要新设置密码 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
用:SET PASSWORD = PASSWORD('123456') 设置密码时又提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
原因是密码验证规则问题,用 set global validate_password_policy=0; 修改后成只验证长度,再执行:
SET PASSWORD = PASSWORD('123456') 就成功了。