开放Fedora10自带的MySQL5.0.67的对外数据库服务

MySQL5.0.67是Fedora10安装时的可选项目。

测试的笔记本IP为192.168.0.100,作为安装Fedora10和MySQL5.0.67的服务器BlackMachine的IP地址为192.168.0.104.

以下是对MySQL的配置过程。

查看/etc/my.cnf文件

[root@blackmachine ~]# cd /etc/
[root@blackmachine etc]# vi my.cnf


my.cnf文件内容如下,可作为参照,不需要进行修改。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# To allow mysqld to connect to a MySQL Cluster management daemon, uncomment
# these lines and adjust the connectstring as needed.
#ndbcluster
#ndb-connectstring="nodeid=4;host=localhost:1186"

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[ndbd]
# If you are running a MySQL Cluster storage daemon (ndbd) on this machine,
# adjust its connection to the management daemon here.
# Note: ndbd init script requires this to include nodeid!
connect-string="nodeid=2;host=localhost:1186"

[ndb_mgm]
# connection string for MySQL Cluster management tool
connect-string="host=localhost:1186"

设定Root的密码:

[root@blackmachine etc]# /usr/bin/mysqladmin -u root password '123456'

 

进入/usr/bin目录

[root@blackmachine etc]# cd /usr/bin

进入MySQL管理,进行授权
[root@blackmachine bin]#  ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.67 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> grant all privileges on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,update,insert,delete on *.* to root@192.168.0.100 identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

重启下mysqld服务是否正常

[root@blackmachine bin]# service mysqld restart
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]

很好,然后再次进入数据库管理界面,又一次设定root的密码。

[root@blackmachine bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.67 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password('12345678') where user='root';
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

修改/etc/sysconfig/iptables文件,增加3306对外端口。

[root@blackmachine bin]# vi /etc/sysconfig/iptables

/etc/sysconfig/iptables的内容,其中粗体一行为新加的。
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

重启下防火墙

[root@blackmachine bin]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

查看系统中已经启动的网络连接和对应的端口信息,3306应该在列

[root@blackmachine bin]# netstat -tlnpu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      6786/mysqld         
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1473/rpcbind        
tcp        0      0 0.0.0.0:38098               0.0.0.0:*                   LISTEN      1486/rpc.statd      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1886/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1974/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1903/sendmail: acce
tcp        0      0 :::111                      :::*                        LISTEN      1473/rpcbind        
tcp        0      0 :::22                       :::*                        LISTEN      1886/sshd           
udp        0      0 0.0.0.0:800                 0.0.0.0:*                               1473/rpcbind        
udp        0      0 0.0.0.0:34732               0.0.0.0:*                               1486/rpc.statd      
udp        0      0 0.0.0.0:814                 0.0.0.0:*                               1486/rpc.statd      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1846/dhclient       
udp        0      0 0.0.0.0:36057               0.0.0.0:*                               1964/avahi-daemon:  
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               1964/avahi-daemon:  
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1473/rpcbind        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1974/cupsd          
udp        0      0 :::800                      :::*                                    1473/rpcbind        
udp        0      0 :::111                      :::*                                    1473/rpcbind        
[root@blackmachine bin]#

看到3306在列后,就可以通过192.168.0.100上的数据库客户端软件进行连接测试了

 

以上画面表征测试通过。

《全文完,纰漏不足之处烦请指出,谢谢!》

posted @   逆火狂飙  阅读(277)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东
点击右上角即可分享
微信分享提示