centos 5.5 安装mysql 5.5 全程详细记录 RPM方式安装
2012-11-16 16:32
821 查看
#rpm –qa|grep –i mysql查看已安装的mysql版本
如果有已存在的mysql版本则删除
安装服务端和客户端,去ORACLE官网下载:
# rpm -ivh MySQL-server-5.5.28-1.linux2.6.i386.rpm
# rpm -ivh MySQL-client-5.5.28-1.linux2.6.i386.rpm
安装后会出现以下信息,提示不要忘记设计root用户的密码以及其他信息。
之后查看mysql的服务是否启动#netstat -nat
如看到有3306的端口号,就说明服务启动了,默认的端口是3306 ,如果没有启动的话 ,就打开服务 #service mysql start 启动mysql服务。
然后再输入mysql,若出现以下提示信息,说明成功。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
进入mysql数据库后:[b]mysql>use mysql;[/b]
然后查看一下root的情况select user,password form user;
修改密码update user set password=password(‘newpassword’)where user=’root’ and host=’root’ or host=’localhost’;
至此mysql是安装成功了的。
但是远程访问还是不行的,还有两个地方,第一是数据库设置,第二是防火[b][b]墙[/b]。一般数据库已经是可以直接连接成功的了。只是没有ROOT权限,如果连不上,像我这样的,肯定是被防火[b][b]墙[/b][/b]挡住了。[/b]
数据库的MYSQL表中控制的可来访的权限,因此我们要改一下它,这样我们就有ROOT权限了。
修改一个root用户的host为你的ip地址
update user u set u.host = 'your_ipaddress' where u.user = root and u.host = 'localhost';
update user u set u.host = '192.168.1.42' where u.user = root and u.host = 'localhost';
或干脆
[b]update user u set u.host = '%' where u.user = root and u.host = 'localhost';
[/b]
重启服务:service mysql restart
加了密码以后,主机现在不能用MYSQL命令直接进去了。需要打成MYSQL -P ,然后可以输你刚才更新的密码才可以进。
然后是最吭爹的防火[b]墙,我被它卡了很久。[/b]
设置CentOS防火墙开放端口方法如下:
打开iptables的配置文件:vi /etc/sysconfig/iptables
在一大串-A RH-Firewall-1-INPU。。。。。的后面添加:-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
或是直接复制有一个控制22端口的,粘一下,直接改成3306也省事。
重启防火墙就可以了。
暂停iptables服务
# service iptables stop
重启iptables服务
# service iptables start
如果有已存在的mysql版本则删除
安装服务端和客户端,去ORACLE官网下载:
# rpm -ivh MySQL-server-5.5.28-1.linux2.6.i386.rpm
# rpm -ivh MySQL-client-5.5.28-1.linux2.6.i386.rpm
安装后会出现以下信息,提示不要忘记设计root用户的密码以及其他信息。
之后查看mysql的服务是否启动#netstat -nat
如看到有3306的端口号,就说明服务启动了,默认的端口是3306 ,如果没有启动的话 ,就打开服务 #service mysql start 启动mysql服务。
然后再输入mysql,若出现以下提示信息,说明成功。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
进入mysql数据库后:[b]mysql>use mysql;[/b]
然后查看一下root的情况select user,password form user;
修改密码update user set password=password(‘newpassword’)where user=’root’ and host=’root’ or host=’localhost’;
至此mysql是安装成功了的。
但是远程访问还是不行的,还有两个地方,第一是数据库设置,第二是防火[b][b]墙[/b]。一般数据库已经是可以直接连接成功的了。只是没有ROOT权限,如果连不上,像我这样的,肯定是被防火[b][b]墙[/b][/b]挡住了。[/b]
数据库的MYSQL表中控制的可来访的权限,因此我们要改一下它,这样我们就有ROOT权限了。
修改一个root用户的host为你的ip地址
update user u set u.host = 'your_ipaddress' where u.user = root and u.host = 'localhost';
update user u set u.host = '192.168.1.42' where u.user = root and u.host = 'localhost';
或干脆
[b]update user u set u.host = '%' where u.user = root and u.host = 'localhost';
[/b]
重启服务:service mysql restart
加了密码以后,主机现在不能用MYSQL命令直接进去了。需要打成MYSQL -P ,然后可以输你刚才更新的密码才可以进。
然后是最吭爹的防火[b]墙,我被它卡了很久。[/b]
设置CentOS防火墙开放端口方法如下:
打开iptables的配置文件:vi /etc/sysconfig/iptables
在一大串-A RH-Firewall-1-INPU。。。。。的后面添加:-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
或是直接复制有一个控制22端口的,粘一下,直接改成3306也省事。
重启防火墙就可以了。
暂停iptables服务
# service iptables stop
重启iptables服务
# service iptables start
相关文章推荐
- centos 5.5 安装mysql 5.5 全程详细记录 RPM方式安装
- CentOS6.5下RPM方式安装mysql5.6.33的详细教程
- linux centos(5.6)使用rpm方式安装mysql(5.5)时候报错:error:failed dependencies
- CentOS6.5下RPM方式安装mysql5.6.33的详细教程
- Centos 6.5下以RPM方式安装MySQL5.6.16(详细版)
- CentOS 6.4  安装mysql 5.5 rpm 的libaio问题的解决
- CentOS 6.5下RPM方式(重新)安装MySQL 5.7.21从头到尾篇
- centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解
- CentOS下成功以rpm方式安装Mysql 5.5.13
- 3、在CentOS release 6.4 下mysql的rpm方式的安装
- CentOS6.6环境编译安装MySQL 5.6的详细记录
- CentOS下RPM方式安装MySQL5.6(转载)
- 关于linux-Centos 7下mysql 5.7.9的rpm包的安装方式
- 关于linux-Centos 7下mysql 5.7.9的rpm包的安装方式
- LNMP 最新版本+YUM方式安装指南(CentOS5.5 + Nginx 1.0.x + MySQL 5.5.x + PHP 5.3.x)
- 关于linux-Centos 7下mysql 5.7.9的rpm包的安装方式
- 关于linux-Centos 7下mysql 5.7.9的rpm包的安装方式 (转)
- CentOS6.8 x64 安装MySQL 5.6.38 rpm方式
- CentOS6.6-64下rpm方式mysql-5.7.12安装实录
- [置顶]CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]