1.mysqladmin -uroot -poldpassword password newpassword
2.mysql> update mysql.user set password=PASSWORD("新密码") where User="root";
mysql> flush privileges;
mysql> quit
3.mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user="name";
mysql> FLUSH PRIVILEGES;
mysql> QUIT
4.可以修改MYSQL文件夹中的MY.INI文件5.使用SET PASSWORD语句,
mysql> SET PASSWORD FOR myuser@localhost = PASSWORD("mypasswd"); 6.使用GRANT ... IDENTIFIED BY语句
mysql> GRANT USAGE ON *.* TO myuser@localhost IDENTIFIED BY "mypassword"; 在windows下:
打开命令行窗口,停止mysql服务:Net stop mysql
到mysql的安装路径启动mysql,在bin目录下使用mysqld-nt.exe启动,在命令行窗口执行:mysqld-nt --skip-grant-tables
然后另外打开一个命入令行窗口,执行mysql,此时无需输入密码即可进入。
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
>exit
使用任务管理器,找到mysqld-nt的进程,结束进程!
在重新启动mysql-nt服务,就可以用新密码登录了。在linux下:
如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
重新杀 MySQL ,用正常方法启动 MySQL 。 1)停止windows服务中的mysql实例 2)使用–skip-grant-tables 参数启动mysql,这种模式下,无需root密码就可以登陆mysql.mysqld-max-nt –skip-grant-tables 3)登陆mysql,修改密码C:Documents and Settingsinzhang>mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 5.0.27-community-max-nt
Type "help;" or "h" for help. Type "c" to clear the buffer.mysql> use mysql;
Database changed
mysql> update user set password=password("root") where user="root";
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0 php+mysql数据库编程学习小细节Windows与Linux下MySQL的细小区别相关资讯 linux mysql
- Linux下MySQL的简单操作笔记 (08/12/2015 10:50:28)
- Linux下MySQL报Table "xxx" doesn" (11/22/2014 07:37:47)
- Linux下解决MySQL无法远程连接问题 (11/14/2013 07:18:33)
| - Linux开启MySQL远程连接 (11/22/2014 07:40:48)
- Linux系统MySQL数据库远程设置 (01/10/2014 09:35:35)
- Linux网站架构系列之MySQL----部署 (11/06/2013 20:21:28)
|
本文评论 查看全部评论 (0)