1、mysql权限修改
1.1 进入mysql控制台
- mysql -u root -p mysql //<span style="white-space: pre;">第一个</span>mysql是执行命令,第二个mysql是系统数据库
如果顺利进入mysql控制台,请跳到1.2步骤。
如果出现修改密码时修改错误,比如:
- update user set password='123456' where user = 'root';
- update user set password=PASSWORD('123456') where user='root';
依照上面那种修改密码,会导致的错误有:
- ERROR 1045(28000) :Access denied for user ''@'localhost' (using password:No)
1.1.1 关闭mysql
- service mysqld stop
- mysqld_safe --skip-grant-table
- mysql -u root mysql
- UPDATE user SET password=PASSWORD('123456') WHERE user='root';
- flush privileges;//记得要执行这句话,否则如果关闭先前的终端,又出现原来的错误
- exit;
- grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
- //root 是用户名,% 表示任意主机,'123456' 指定的登录密码(这个和本地的root密码可以设置不同,互不影响)
- flush privileges; //重载系统权限
- exit;//退出mysql控制台
2.CentOS环境开放3306端口
添加规则,打开3306端口
- iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
查看规则是否生效
- iptables -L -n //或者 service iptables status
- </pre><pre name="code" class="html">iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
注意:上面使用iptables添加/删除规则都是临时的,如果需要重启也生效,就要保存修改:
- service iptables save //或者 /etc/init.d/iptables save
- vi /etc/sysconfig/iptables //在该文件中加入下面这条规则也是可以生效的
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
3.1修改rc.local文件
- vi /etc/rc.d/rc.local
- /etc/rc.d/init.d/mysqld start
先查看所有自动启动服务
- chkconfig --list //指定查看 chkconfig --list mysqld
- chkconfig --add mysqld
- chkconfig mysqld on
- chkconfig --list mysqld
结果显示:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off表示在系统级别为:2、3、4、5时自动启动