先停止mysqld
# mysqld_safe --skip-grant-tables &
# use mysql;
# update user set password=password('yes') where user="root"; ---将root密码设置为yes
# flush privileges;
# exit
# ps -ef | grep mysql //如果发现安全模式还没有关掉需要 kill -9 干掉
# service mysqld stop
# service mysqld start
# mysql -uroot -p
#输入新密码后登陆
数据库权限操作
1、创建用户并设定密码
#create user 'test'@'localhost'> #SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword') //设置或配置用户密码
2、开启mysql 数据库远程连接授权
#create user 'frog'@'192.168.10.117'>
#grant all privileges on *.* to frog@192.168.10.117> #flush privileges; //更新缓存
3、给用户指定数据库权限:mysql 为账号 abc@123为密码;
#grant all privileges on wordpress_db.* to mysql@localhost> 4、用户名'mysql'@'%' 之间不允许有空格,%可以换成特定地址,%代表任何主机都可以访问