mariadb

推荐列表 站点导航

当前位置:首页 > 数据库 > mariadb >

Mariadb远程登陆配置及问题解决

来源:网络整理  作者:wy  发布时间:2020-12-24 15:52
这篇文章主要介绍了Mariadb远程登陆配置及问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一...

  安装过程不再赘述,直接说问题,mysql的远程连接需要解决两个问题:1.允许root用户远程连接。2.允许任意ip远程连接数据库。当然,在测试和解决问题之前,得首先保证你的数据库与远程主机之间的网络通信没有问题,简单的来说,就是互相ping通,其次,为了避免防火墙的干扰,将本地主机和数据库主机的防火墙都关闭,当然,生产环境下防火墙肯定是要打开的,并且需要额外的安全配置。

问题解决:

1.新安装的数据库默认是需要初始化的,在数据库服务启动的情况下,使用下面的命令来进行初始化。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

 

[root@localhost ~]# mysql_secure_installation

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n]

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n  #如果是为root用户配置远程登陆,这里需要选择n,不选择禁止root用户远程登陆,别的选择都无关紧要。

 ... skipping.

 

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n]

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n]

 ... Success!

 

Cleaning up...

 

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB![root@localhost ~]# systemctl restart mariadb  #完成初始化之后,重启服务。

 

2.允许root用户远程连接与允许任意ip远程连接数据库都是可以通过在数据库里执行一条命令来实现的。

这里分为两种情况:

1)新建admin用户远程连接mysql数据库(新建任意用户,以admin为例)

grant all on IT之家.IT之家 to admin@'%' identified by '123456' with grant option;
flush privileges;

允许任何ip地址(%表示允许任何ip地址)的电脑用admin帐户和密码(123456)来访问这个mysql server。
注意admin账户不一定要存在。

2)支持root用户允许远程连接mysql数据库

grant all privileges on IT之家.IT之家 to 'root'@'%' identified by '123456' with grant option;
flush privileges;

需要注意的是,为root用户配置远程登陆,密码需要和之前配置的密码一致。

3.ubuntu系统的额外配置。

Ubuntu系统的my.cnf文件在vim /etc/mysql/mysql.conf.d/mysqld.cnf中,注释掉其中的

bind-address = 127.0.0.1

centos系统的配置文件中默认没有该行。

检查的办法也很简单,在数据库启动的前提下,使用netstat -an | grep 3306查看端口的连接信息。0.0.0.0则表示允许任意IP连接。

如图所示则为允许任意IP连接。

相关热词: 解决 配置

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/sql/mariadb/8567.shtml

最新文章
mariadb 在低配 VPS 上崩溃问 mariadb 在低配 VPS 上崩溃问

时间:2020-12-25

centos 7安装mysql5.5和安装 centos 7安装mysql5.5和安装

时间:2020-12-25

Mysql/MariaDB启动时处于进度 Mysql/MariaDB启动时处于进度

时间:2020-12-25

详谈MySQL和MariaDB区别与性 详谈MySQL和MariaDB区别与性

时间:2020-12-24

浅谈MySQL和mariadb区别 浅谈MySQL和mariadb区别

时间:2020-12-24

MySQL分支选择参考:Perco MySQL分支选择参考:Perco

时间:2020-12-24

Windows10系统下安装MariaDB Windows10系统下安装MariaDB

时间:2020-12-24

我是如何用2个Unix命令给 我是如何用2个Unix命令给

时间:2020-12-24

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

Mariadb远程登陆配置及问题解决

2020-12-24 编辑:wy

  安装过程不再赘述,直接说问题,mysql的远程连接需要解决两个问题:1.允许root用户远程连接。2.允许任意ip远程连接数据库。当然,在测试和解决问题之前,得首先保证你的数据库与远程主机之间的网络通信没有问题,简单的来说,就是互相ping通,其次,为了避免防火墙的干扰,将本地主机和数据库主机的防火墙都关闭,当然,生产环境下防火墙肯定是要打开的,并且需要额外的安全配置。

问题解决:

1.新安装的数据库默认是需要初始化的,在数据库服务启动的情况下,使用下面的命令来进行初始化。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

 

[root@localhost ~]# mysql_secure_installation

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n]

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n  #如果是为root用户配置远程登陆,这里需要选择n,不选择禁止root用户远程登陆,别的选择都无关紧要。

 ... skipping.

 

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n]

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n]

 ... Success!

 

Cleaning up...

 

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB![root@localhost ~]# systemctl restart mariadb  #完成初始化之后,重启服务。

 

2.允许root用户远程连接与允许任意ip远程连接数据库都是可以通过在数据库里执行一条命令来实现的。

这里分为两种情况:

1)新建admin用户远程连接mysql数据库(新建任意用户,以admin为例)

grant all on IT之家.IT之家 to admin@'%' identified by '123456' with grant option;
flush privileges;

允许任何ip地址(%表示允许任何ip地址)的电脑用admin帐户和密码(123456)来访问这个mysql server。
注意admin账户不一定要存在。

2)支持root用户允许远程连接mysql数据库

grant all privileges on IT之家.IT之家 to 'root'@'%' identified by '123456' with grant option;
flush privileges;

需要注意的是,为root用户配置远程登陆,密码需要和之前配置的密码一致。

3.ubuntu系统的额外配置。

Ubuntu系统的my.cnf文件在vim /etc/mysql/mysql.conf.d/mysqld.cnf中,注释掉其中的

bind-address = 127.0.0.1

centos系统的配置文件中默认没有该行。

检查的办法也很简单,在数据库启动的前提下,使用netstat -an | grep 3306查看端口的连接信息。0.0.0.0则表示允许任意IP连接。

如图所示则为允许任意IP连接。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/sql/mariadb/8567.shtml

相关文章

风云图片

推荐阅读

返回mariadb频道首页