JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 服务器 » linux修改mysql远程访问,MySql实现远程连接,mysql开启远程登录,MySql操作以及一些错误处理

linux修改mysql远程访问,MySql实现远程连接,mysql开启远程登录,MySql操作以及一些错误处理

还是因为vps的原因换了一个linux-vps 下面是我在linux系统下的myslq配置 安装完mysql后就是链接使用它了 mysqladmin -u root -p oldpass newpass 因为新安装的myslq密码都是空的 所以上面就直接设置了新密码 然后进入mysql mysql -u root -p Enter password: 这里是你刚刚设置的密码 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 Server version: 5.1.61 Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> //然后查看用户和主机 select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | ::1 | | root | 127.0.0.1 | | root | localhost | +------+-----------+ 3 rows in set (0.00 sec) 修改host: mysql> update mysql.user set host='%' where user='root'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'//出现错误 #修改host值(以通配符%的内容增加主机/IP地址,当然也可以直接增加某个特定IP地址,如果执行update语句时出现ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 错误,需要select host from user where user = 'root'; 查看一下host是否已经有了%这个值,如果有了直接执行下面的flush privileges;即可) 执行了flush privileges; 我们再来查看一下数据: mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select host,user from user; +-----------+------+ | host | user | +-----------+------+ | % | root | | 127.0.0.1 | root | | localhost | root | +-----------+------+ 3 rows in set (0.00 sec) 然后再给没有密码的用户加上密码。 mysql> update user set password=password('123456') where host='127.0.0.1' or host='localhost'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 配置差不多了,可以远程访问了!

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号