1:下载社区版的mysql,
要下载两个文件,分别为:MySQL-server-community-5.1.46-1.rhel5.i386.rpm
MySQL-client-community-5.1.46-1.rhel5.i386.rpm
客户端和服务器
下载地址页:http://www.mysql.com/downloads/mysql/#downloads
2:安装服务器:
(1)在当前安装文件目录下,执行命令,
[root@localhost ~]#rpm -ivh MySQL-server-community-5.1.46-1.rhel5.i386.rpm
注:rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数 是–ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现“#”符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。
此步骤出现的错误:
error: Failed dependencies:
mysql is needed by bind-9.5.0-16.a6.fc8.i386
象这样类型的错误很有可能是你系统里面安装了与现在的版本相冲突的软件包,或者是缺少关联包
安装时显示如下信息。
warning: MySQL-server-4.0.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
。。。。。。(省略显示)
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h test1 password 'new-password'
。。。。。。(省略显示)
Starting mysqld daemon with databases from /var/lib/mysql
如出现如上信息,服务端安装完毕。测试是否成功可运行netstat看Mysql端口是否打开,如打开表示服务已经启动,安装成功。Mysql默认的端口是3306。
[root@localhost ~]#netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
上面显示可以看出MySQL服务已经启动。
3:安装客户端:
运行如下命令:
[root@localhost ~]# MySQL-client-community-5.1.46-1.rhel5.i386.rpm
显示的安装信息如下:
warning: MySQL-client-4.0.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
显示安装完毕。
4:修改登陆密码:
MySQL默认没有密码,
2、例子
例
(1):给root加个密码123456。
[root@localhost ~]# /usr/bin/mysqladmin -u root password 123456
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
(2):用修改后的密码登录
[root@localhost ~]# mysql -u root -p
Enter password: (输入修改后的密码123456)
Welcome to the MySQL monitor. Commands end with ; or //g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type /'help;/' or /'//h/' for help. Type /'//c/' to clear the buffer.
mysql>
成功!
5:启动服务;
[root@localhost ~]# /etc/init.d/mysql start
6:停止服务:
[root@localhost ~]# /usr/bin/mysqladmin -u root -p shutdown
7:自动启动
1)察看mysql是否在自动启动列表中
[root@test1 local]# /sbin/chkconfig –list
2)把MySQL添加到你系统的启动服务组里面去
[root@test1 local]# /sbin/chkconfig – add mysql
3)把MySQL从启动服务组里面删除。
[root@test1 local]# /sbin/chkconfig – del mysql
以上就是安装mysql的基本操作步骤,其它详细资料可以查找资料