centos安装mysql

本文详细介绍在CentOS系统上安装MySQL的过程,包括卸载旧版本、安装新版本及更改端口等步骤,并提供具体命令实例。

1.准备工作

到mysql官方网站 http://www.mysql.com/downloads/ 

               或者 http://mirrors.sohu.com/

 

我安装的操作系统是CentOs_5_5_64_server

 

下载mysql-RPM文件,一共2个:

MySQL-server-community-5.1.52-1.rhel5.x86_64.rpm

MySQL-client-community-5.1.52-1.rhel5.x86_64.rpm

 

将下载完的存放在根目录/tmp/,临时目录中

写道
[root@test-db-100 ~]# cd /tmp/
[root@test-db-100 tmp]# ll
total 88764
-rw-r--r-- 1 root root 7518553 Nov 10 17:54 MySQL-client-community-5.1.52-1.rhel5.x86_64.rpm
-rw-r--r-- 1 root root 21367106 Nov 10 17:51 MySQL-server-community-5.1.52-1.rhel5.x86_64.rpm

 

 2.安装mysql

 

新装的CentOs中一般都预装了mysql

 

可以先用rpm命令

写道
[root@test-db-100 tmp]# rpm -qa |grep -i  mysql
mysql-5.0.77-4.e15_5.3.x86_64

 

命令检索一下

 

这是需要使用

写道
[root@test-db-100 tmp]# rpm -e mysql-5.0.77-4.e15_5.3.x86_64

 

卸载旧的mysql,这是可能会提示错误

写道
error: Failed dependencies: 
        libmysqlclient.so.15()(64bit) is needed by (installed) dovecot-1.0.7-7.e15.x86_64
        libmysqlclient.so.15(libmysqlclient_15)(64bit) is needed by (installed) dovecot-1.0.7-7.e15.x86_64

 因为mysql-5.0.77-4.e15_5.3.x86_64依赖了dovecot-1.0.7-7.e15.x86_64

 所以要先卸载dovecot-1.0.7-7.e15.x86_64,再卸载mysql-5.0.77-4.e15_5.3.x86_64

写道
[root@test-db-100 tmp]# rpm -e dovecot-1.0.7-7.e15.x86_64
[root@test-db-100 tmp]# rpm -e mysql-5.0.77-4.e15_5.3.x86_64

 

这时,可以安装了~

先server,然后client!

写道
[root@test-db-100 tmp]# rpm -ivh MySQL-server-community-5.1.52-1.rhel5.x86_64.rpm
写道
[root@test-db-100 tmp]# rpm -ivh MySQL-client-community-5.1.52-1.rhel5.x86_64.rpm

 

等待一会儿,提示OK

测试一下:

写道
[root@test-db-100 /]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.1.52-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 可以进去,说明安装成功!

 

3.如果需要修改端口,那么看继续下去

 

首要要确定mysql安装哪里了,以为我们需要创建my.cnf这个文件

 

使用find命令

写道
[root@test-db-100 /]# find / -name mysql
/var/lock/subsys/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/share/mysql
/usr/lib64/mysql
/usr/bin/mysql
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql
[root@test-db-100 /]#

 接下来根据这些路径,看看到底安装到哪里了~

 CentOs默认安装完的mysql是在/usr/share/mysql 路径的

 

写道
[root@test-db-100 /]# cd /usr/share/mysql/
[root@test-db-100 mysql]# ll
total 1372
-rwxr-xr-x 1 root root 1153 Oct 12 09:53 binary-configure
-rwxr-xr-x 1 root root 81791 Oct 12 09:52 ChangeLog
drwxr-xr-x 2 root root 4096 Nov 11 21:13 charsets
-rwxr-xr-x 1 root root 3805 Oct 12 09:53 config.huge.ini
-rwxr-xr-x 1 root root 1661 Oct 12 09:53 config.medium.ini
-rwxr-xr-x 1 root root 905 Oct 12 09:53 config.small.ini
drwxr-xr-x 2 root root 4096 Nov 11 21:13 czech
drwxr-xr-x 2 root root 4096 Nov 11 21:13 danish
drwxr-xr-x 2 root root 4096 Nov 11 21:13 dutch
drwxr-xr-x 2 root root 4096 Nov 11 21:13 english
-rwxr-xr-x 1 root root 416246 Oct 12 09:52 errmsg.txt
drwxr-xr-x 2 root root 4096 Nov 11 21:13 estonian
-rwxr-xr-x 1 root root 603118 Oct 12 09:52 fill_help_tables.sql
drwxr-xr-x 2 root root 4096 Nov 11 21:13 french
drwxr-xr-x 2 root root 4096 Nov 11 21:13 german
drwxr-xr-x 2 root root 4096 Nov 11 21:13 greek
drwxr-xr-x 2 root root 4096 Nov 11 21:13 hungarian
drwxr-xr-x 2 root root 4096 Nov 11 21:13 italian
drwxr-xr-x 2 root root 4096 Nov 11 21:13 japanese
drwxr-xr-x 2 root root 4096 Nov 11 21:13 korean
-rwxr-xr-x 1 root root 5006 Oct 12 09:52 mi_test_all
-rwxr-xr-x 1 root root 1517 Oct 12 09:52 mi_test_all.res
-rwxr-xr-x 1 root root 4780 Oct 12 09:53 my-huge.cnf
-rwxr-xr-x 1 root root 20164 Oct 12 09:53 my-innodb-heavy-4G.cnf
-rwxr-xr-x 1 root root 4754 Oct 12 09:53 my-large.cnf
-rwxr-xr-x 1 root root 4765 Oct 12 09:53 my-medium.cnf
-rwxr-xr-x 1 root root 2403 Oct 12 09:53 my-small.cnf
-rwxr-xr-x 1 root root 1061 Oct 12 09:53 mysqld_multi.server
-rwxr-xr-x 1 root root 43941 Oct 12 09:52 mysql_fix_privilege_tables.sql
-rwxr-xr-x 1 root root 789 Oct 12 09:53 mysql-log-rotate
-rwxr-xr-x 1 root root 12227 Oct 12 09:53 mysql.server
-rwxr-xr-x 1 root root 1878 Oct 12 09:52 mysql_system_tables_data.sql
-rwxr-xr-x 1 root root 16527 Oct 12 09:52 mysql_system_tables.sql
-rwxr-xr-x 1 root root 9669 Oct 12 09:52 mysql_test_data_timezone.sql
-rwxr-xr-x 1 root root 589 Oct 12 09:53 ndb-config-2-node.ini
drwxr-xr-x 2 root root 4096 Nov 11 21:13 norwegian
drwxr-xr-x 2 root root 4096 Nov 11 21:13 norwegian-ny
drwxr-xr-x 2 root root 4096 Nov 11 21:13 polish
drwxr-xr-x 2 root root 4096 Nov 11 21:13 portuguese
drwxr-xr-x 2 root root 4096 Nov 11 21:13 romanian
drwxr-xr-x 2 root root 4096 Nov 11 21:13 russian
drwxr-xr-x 3 root root 4096 Nov 11 21:13 SELinux
drwxr-xr-x 2 root root 4096 Nov 11 21:13 serbian
drwxr-xr-x 2 root root 4096 Nov 11 21:13 slovak
drwxr-xr-x 2 root root 4096 Nov 11 21:13 spanish
drwxr-xr-x 2 root root 4096 Nov 11 21:13 swedish
drwxr-xr-x 2 root root 4096 Nov 11 21:13 ukrainian
[root@test-db-100 mysql]#

这是我们所需要的:my-large.cnf  配置大型mysql 

                       my-medium.cnf 配置中型mysql

                       my-small.cnf 配置小型mysql

一共3种,看各自的需求

 

配置个简单的,就用my-small.cnf

 

我们需要将my-small.cnf拷贝到根目录,并创建我们需要的my.cnf

 

写道
[root@test-db-100 mysql]# cp my-small.cnf /etc/my.cnf

 到etc目录下,编辑my.cnf,默认的port为3306

写道
[root@test-db-100 etc]# vim my.cnf
# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 18888
socket = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 18888
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id = 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

 :wq写入保存

 

因为我们修改了配置文件,所以需要重启mysql服务

写道
[root@test-db-100 etc]# service mysql restart

 

经过修改的port就生效了,修改mysql端口成功!

 

 

为自己鼓掌.....为自己撒花.....花费了1个多小时,终于写完了~

 

 

采用PyQt5框架与Python编程语言构建图书信息管理平台 本项目基于Python编程环境,结合PyQt5图形界面开发库,设计实现了一套完整的图书信息管理解决方案。该系统主要面向图书馆、书店等机构的日常运营需求,通过模块化设计实现了图书信息的标准化管理流程。 系统架构采用典型的三层设计模式,包含数据存储层、业务逻辑层和用户界面层。数据持久化方案支持SQLite轻量级数据库与MySQL企业级数据库的双重配置选项,通过统一的数据库操作接口实现数据存取隔离。在数据建模方面,设计了包含图书基本信息、读者档案、借阅记录等核心数据实体,各实体间通过主外键约束建立关联关系。 核心功能模块包含六大子系统: 1. 图书编目管理:支持国际标准书号、中国图书馆分类法等专业元数据的规范化著录,提供批量导入与单条录入两种数据采集方式 2. 库存动态监控:实时追踪在架数量、借出状态、预约队列等流通指标,设置库存预警阈值自动提醒补货 3. 读者服务管理:建立完整的读者信用评价体系,记录借阅历史与违规行为,实施差异化借阅权限管理 4. 流通业务处理:涵盖借书登记、归还处理、续借申请、逾期计算等标准业务流程,支持射频识别技术设备集成 5. 统计报表生成:按日/月/年周期自动生成流通统计、热门图书排行、读者活跃度等多维度分析图表 6. 系统维护配置:提供用户权限分级管理、数据备份恢复、操作日志审计等管理功能 在技术实现层面,界面设计遵循Material Design设计规范,采用QSS样式表实现视觉定制化。通过信号槽机制实现前后端数据双向绑定,运用多线程处理技术保障界面响应流畅度。数据验证机制包含前端格式校验与后端业务规则双重保障,关键操作均设有二次确认流程。 该系统适用于中小型图书管理场景,通过可扩展的插件架构支持功能模块的灵活组合。开发过程中特别注重代码的可维护性,采用面向对象编程范式实现高内聚低耦合的组件设计,为后续功能迭代奠定技术基础。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值