CentOS刚装的MySQL通常须要重设MySQL密码,能够用如下方法重设。
方法1、
Js代码
# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
方法2、
Js代码
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password: <输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql
MySQL> sql
1.1 支持远程访问:(这个不行请看1.2)数据库
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'; --%能够改为ip或者其余
mysql>select host, user from user;
服务器
重启数据库dom
mysql不容许远程用户访问主机服务器 1130
安装完以后成 使用 mysql admin链接报错
ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server
如下百度查到的,试过能够
说明所链接的用户账号没有远程链接的权限,只能在本机(localhost)登陆。
需更改 mysql 数据库里的 user表里的 host项
把localhost改称%
具体步骤:登录到mysql
首先 use mysql;
按照别人提供的方式update的时候,出现错误。
mysql> update user set host='%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
而后查看了下数据库的host信息以下:
mysql> select host from user where user = 'root';
+-----------------------+
| host |
+-----------------------+
| % |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in set (0.00 sec)
host已经有了%这个值,因此直接运行命令:
mysql>flush privileges;
再用mysql administrator链接...成功!!!ui