(1)防火墙关闭
service iptables stop
chkconfig iptables off:开机不启动防火墙
(2)关闭selinux
安装mysql
(1)卸载linux自带mysql包
rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64(输入这行代码 )
检查:rpm -qa | grep mysql(在检查一遍 还有没有这个包)
(2)通过yum安装mysql
yum instal -y mysql-server(输入这段命令会自动下载mysql 主要linux 需要联网)
成功的话,可以看到“Complete!”
默认安装的是5.1.73
(3)启动mysql服务
service mysqld start
如果是5.1的版本,mysql的服务名称:mysqld
版本>5.5 ,mysql的服务名称:mysql
(4)设置root用户密码,
/usr/bin/mysqladmin -u root password '123456'
验证:
mysql -u root -p
show databases
use mysql
show tables
(5)让mysql服务,随着系统的启动而启动
查看:
chkconfig mysqld --list
修改:
chkconfig mysqld on
查看:
chkconfig mysqld --list
(6)在mysql配置对应的权限
a:授权
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option
b:查询
select host,user,password from user;
经验告诉你,你保留一条:
+------+------+-------------------------------------------+
| host | user | password |
+------+------+-------------------------------------------+
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+------+-------------------------------------------+
c:刷新权限(必须执行)
flush privileges
(7)重启mysql服务
service mysqld restart