Mysql --rpm 包 安装

下载mysql 地址:http://www.mysql.com/downloads/mysql/#downloads

进入后会有选择系统



选择linux-generic后 又有很多产品选择,我们只下载以下2个就可以了

server:

Linux - Generic 2.6 (x86, 32-bit), RPM Package
MySQL Server  5.5.25a 49.3M Download
(MySQL-server-5.5.25a-1.linux2.6.i386.rpm) MD5: e74d95d21a1237a990c3e0491e6abb93


client:
Linux - Generic 2.6 (x86, 32-bit), RPM Package
Client Utilities  5.5.25a 16.1M Download
(MySQL-client-5.5.25a-1.linux2.6.i386.rpm) MD5: 134df314872425c8c8cede8f4508b785


进入下载文件所以目录进行安装

如:

> chomod +x MySQL-server-5.5.25a-1.linux2.6.i386.rpm
> chomod +x MySQL-client-5.5.25a-1.linux2.6.i386.rpm

> rpm -ivh MySQL-server-5.5.25a-1.linux2.6.i386.rpm

> rpm -ivh MySQL-client-5.5.25a-1.linux2.6.i386.rpm

启动mysql

> service mysql start



登录MySQL的命令是mysql, mysql 的使用语法如下:
  mysql [-u username] [-h host] [-p[password]] [dbname]
  username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。

然后输入mysql

root@test1 local]# mysql
  Welcome to the MySQL monitor. Commands end with ; or \g.
  Your MySQL connection id is 1 to server version: 4.0.16-standard
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql>
出现了“mysql>”提示符,恭喜你,安装成功!

修改登录密码



  MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

  1、命令
  usr/bin/mysqladmin -u root password 'new-password'
  格式:mysqladmin -u用户名 -p旧密码 password 新密码

键入以下命令 :
  [root@test1 local]# /usr/bin/mysqladmin -u root password 123456
  注:因为开始时root没有密码,所以-p旧密码一项就可以省略了

实现MySQL远程连接(改表法)

1. use mysql;

2. update user set host = '%' where user = 'root'; 这样在远端就可以通过root用户访问MySQL.

3.mysql>flush privileges;

如果其他客户端用root 还是不能访问mysql 数据库服务器,查下是不是服务器的防火墙限制了,先运行以下命令把防火墙关了试下能不能连。
[root@localhost ~]# service  iptables stop
Stopping iptables (via systemctl):  [  OK  ]


摘自:http://www.2cto.com/database/201201/117241.html

猜你喜欢

转载自huaye.iteye.com/blog/1593642