Linux + iptables + Mysql 初始配置_MySQL
配置网卡
方法一:把以下命令放在/etc/rc.d/init.d/rc.local文件中
[root@local root]# ifconfig eth0 down
[root@local root]# ifconfig eth0 up
[root@local root]# ifconfig eth0 192.168.0.2 netmask 255.255.255.0
[root@local root]# route add default gw 192.168.1.2
方法二:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=219.136.241.211
NETMASK=255.255.255.128
GATEWAY=192.168.1.1
vi /etc/resolv.conf
nameserver 8.8.8.8
/etc/init.d/network restart
配置防火墙
[root@local root]# vi /etc/sysconfig/iptables
[root@local root]# service iptables restart
yum安装mysql
[root@local root]# yum list | grep mysql
[root@local root]# yum list | grep mysql-server
/sbin/chkconfig –-add mysqld [在服务清单中添加mysql服务]
service mysqld start;(即/etc/init.d/mysqld start。也可设成开机自启动:/sbin/chkconfig mysqld on)
更改 root 密码: mysqladmin -u root password 'newpassword'
添加mysql用户: GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password';
grant all on *.* to "root"@"%" identified by "123456";
(update user set host = ’%’ where user = ’root’;)
重载权限: mysql> FLUSH PRIVILEGES;
删除test数据库: mysql -u root -p mysql> DROP DATABASE test;
删除匿名帐户: DELETE FROM mysql.user WHERE user = '';
关机
shutdown -h now
Windows
route change 0.0.0.0 mask 0.0.0.0 192.168.1.1
上一篇: Python的面向对象思想分析