Linux下利用rpm包安装mysql
来源:互联网 发布:淘宝汽车凹陷修复工具 编辑:程序博客网 时间:2024/04/30 18:06
最近由于项目关系弄了下mysql cluster和mysql,中心数据库用的是mysql cluster,前置机数据库用的是mysql,这是先写下mysql的安装作为以后查看用。
1.软件包准备:在 http://www.mysql.com/downloads/mysql-4.0.html 上下载 MySQL-server-5.5.23-1.linux2.6.i386.rpm 和 MySQL-client-5.5.23-1.linux2.6.i386.rpm
2.安装mysql
1)安装服务器端
在rpm包的目录下运行以下命令:
[root@gc01vm4 local]# rpm -ivh MySQL-server-5.5.23-1.linux2.6.i386.rpm
显示如下信息:“
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h gc01vm4 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script! ”
如出现如上信息,则表示服务器端安装成功
2)安装客户端
运行如下命令
[root@gc01vm4 local]# rpm -ivh MySQL-client-5.5.23-1.linux2.6.i386.rpm
显示如下信息则表明安装成功:
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
3.启用mysql服务
运行如下命令:
[root@gc01vm4 init.d]# /etc/init.d/mysql start 或者用mysqld_safe & 命令来启动数据库
mysql 的默认端口是3306,这时可以 用netstat来查看mysql端口是否打开
[root@gc01vm4 init.d]# netstat -nat
如果显示中有tcp 0 0 :::3306 :::* LISTEN 这条则表示服务已启动。
用ps -e 命令可以查看到进程中有mysqld进程
附:rpm包的卸载:# rpm -qa | grep MySQL
MySQL-server-5.0.27-0.glibc23
然后,
# rpm -e --nodeps MySQL-server-5.0.27-0.glibc23
不行的话可以用#rpm -e --allmatches MySQL-server-5.0.27-0.glibc23 搞定。再
# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
mysql的相关文件应该可以手动删除了 示例 rm -rf /var/lib/mysql
mysql停止:/usr/bin/mysqladmin -u root -p shutdown
rpm命令参数:--force忽略软件包及文件的冲动
--nodeps 不检查依赖性关系
--dbpath设置RPM资料库所在的路径
--prefix 将软件包安装到由指定的目录下
4.登录mysql
第一次登录只需键入mysql
[root@gc01vm4 init.d]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.23 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>
出现如上提示刚表示登录成功
修改密码:[root@gc01vm4 init.d]# /usr/bin/mysqladmin -u root password '111111'
这时将密码改为了六个1,离开mysql键入exit即可,再次登录刚需要输入
[root@gc01vm4 init.d]# mysql -u root -p
Enter password:
输入密码回车即可。
5.mysql的几个重要目录
数据库目录
/var/lib/mysql/
配置文件
/usr/share/mysql(mysql.server命令及配置文件)
相关命令
/usr/bin(mysqladmin mysqldump等命令)
启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
6.建库、建表、插入记录等基本操作
1)建库 mysql> create databases orcl;
2) 打开库 mysql> use orcl; (打开库,对每个库进行操作就要打开此库,类似于foxpro )
Database changed
3) 建表
mysql> create table name (id int(3) auto_increment not null primary key, xm char(8),xb char(2),csny date);
4)查看表结构
mysql> describe name;
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| id | int(3) | | PRI | NULL | auto_increment |
| xm | char(8) | YES | | NULL | |
| xb | char(2) | YES | | NULL | |
| csny | date | YES | | NULL | |
+-------+---------+------+-----+---------+----------------+
mysql> insert into name values('','张三','男','1971-10-01');
mysql> insert into name values('','白云','女','1972-05-20');
可用select命令来验证结果。
mysql> select * from name;
+----+------+------+------------+
| id | xm | xb | csny |
+----+------+------+------------+
| 1 | 张三 | 男 | 1971-10-01 |
| 2 | 白云 | 女 | 1972-05-20 |
+----+------+------+------------+
到这里后面操作跟oracle操作类似了……
- Linux下利用rpm包安装mysql
- Linux环境下利用Rpm包安装Mysql
- Linux下利用rpm包安装和使用mysql
- centos下利用rpm包安装mysql
- linux下mysql的rpm包安装
- linux下mysql rpm 包安装
- linux centos7 下安装mysql (rpm包安装)
- linux安装mysql rpm包
- Linux 安装Mysql rpm包
- Linux下卸载和安装MySQL[rpm包]
- linux下安装mysql数据库服务器(RPM 包)
- Linux下MySQL-5.6.26 RPM包安装
- Linux下基于RPM BUNDLE包安装MySQL
- Linux下rpm包方式离线安装mysql
- Linux下基于RPM BUNDLE包安装MySQL
- Linux利用yum下载rpm安装包
- linux安装mysql一 rpm包安装
- Linux下rpm 安装包方式安装
- 返回顶部功能
- UILabel添加发光效果
- 技术学习网站
- 学习使用SkyEye仿真
- WCF Completed 事件执行多次
- Linux下利用rpm包安装mysql
- 字符串:null与"" 的区别
- 鼠标移到GridView某一行时改变该行的背景色方法
- 主机网络ping通开发板与虚拟机问题
- 如何对字符串首部和尾部的空格进行过滤
- 从开机加电到执行main函数之前的过程(二)
- Unix I/O 性能测试
- 使用SpringMVC注解@RequestParam(value="XXX",required=false)时需要注意的问题
- AAC ADTS LATM 分析