Ubuntu14.04下如何开启Mysql远程访问

在目录/etc/mysql下找到my.cnf,用vim编辑,找到my.cnf里面的

#bind-address           = 127.0.0.1

将其只能本地ip访问的代码进行注释

然后用root登陆Mysql数据库

im@58user:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.53-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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> 

然后在执行

mysql> grant all on *.* to root@'%' identified by '123';
myslq> flush privileges;

最后就可以在远程用刚才创建的用户和密码登陆mysql。

在执行对用户授权密码的时候可能会遇到下面的错误:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解决方法:

先刷新一下权限表。
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容