修改MySQL数据库登陆密码的方法
MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。
(1)命令
/usr/bin/mysqladmin -u root –p ‘old-password’ password 'new-password'
格式:mysqladmin -u用户名 -p旧密码 password 新密码
(2)例子
例1:给root加个密码123456。
键入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
(3)测试是否修改成功
1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO) 显示错误,说明密码已经修改。
2)用修改后的密码登录
[root@test1 local]# mysql -u root -p
Enter password: (输入修改后的密码123456)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
成功!
这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。
相关文档:
http://www.3d308.cn/article.asp?id=37
shell> mysql -u root mysql
mysql> Update user SET Password=PASSWORD('new_password')
Where user='root';
mysql> FLUSH PRIVILEGES;
......
默认情况下Linux内的mysql数据库mysql.user表内的用户权限只是对localhost即本机才能登陆。所以需要更改权限,否则无法使用Mysql Administrator连接服务器,会发生如下所示的错误:
MySQL Administrator 1.1.9配置,连接mysql数据库
Could no ......
运行程序可能会报错:Can’t connect to local MySQL Server through socket ‘/tmp/mysql.sock’
这个错误的提示是说,不能通过’/tmp/mysql.sock’连接到服务器。Mysql.sock是创建与mysqld服务器相关的MySQL通信端点所使用的套接字。而PHP标准配置正是通过’/tmp/mysql.sock’来连接 ......