MySQL修改root密码
在Navicat for MySQL下面直接执行:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
用SET PASSWORD命令
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
用mysqladmin命令
mysqladmin -u root password "newpass"
如果root已经设置过密码,采用如下方法:mysqladmin -u root password oldpass "newpass"
用UPDATE直接编辑user表
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
忘记root密码解决办法
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;
root远程登陆设置
在本机先使用root用户登录:mysql:mysql -u root -p"youpassword"
进行授权操作:mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
重载授权表:FLUSH PRIVILEGES;
数据存放目录修改
打开配置文件 /etc/my.cnf
[mysqld]
datadir=/mysql //修改为自己的数据存放目录
socket=/var/lib/mysql/mysql.sock