mysql初始密码在/var/log/mysqld.log中 ,搜索:temporary password
#mysql -uroot -p 登录mysql
MYSQL密码策略有3级(0,1,2)默认是1。需要数字,大小写字母。为了方便测试,密码策略改为0级
mysql>set global validate_password_policy=0;
将密码最小长度改为4(4为最小值)
mysql>set global validate_password_length=4;
重新设置密码:
mysql>set password="1111";
如果程序中连接MYSQL报“Host '' is not allowed to connect to this MySQL server”
是因为账号设置不允许远程登录,修改如下:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;