CentOS下安装mysql

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,高可用系列 2核4GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: CentOS 5.5下安装mysql-5.0.27          下载mysql-5.0.27.tar.gz:                    解压:tar zxvf mysql-5.

CentOS 5.5下安装mysql-5.0.27
          下载mysql-5.0.27.tar.gz:
          
          解压:tar zxvf mysql-5.0.27.tar.gz
          # cd mysql-5.0.27
          # mkdir /program/mysql
          ---
          # ./configure --prefix=/program/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=gbk --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --with-charset=utf8
          统一编码,都使用utf8
          --with-collation=utf8_general_ci
          --with-charset=utf8
          ---
          mysql编译参数说明:根据 ./configure --help 查看支持配置的参数
          如下链接:
          ---
          错误:checking for termcap functions library... configure: error: No curses/termcap library found
          解决:在configure后增加–with-named-curses-libs=/usr/lib/libncurses.so.5

          # ./configure --prefix=/program/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=gbk --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --with-charset=utf8 --with-named-curses-libs=/usr/lib/libncurses.so.5
          [root@localhost mysql-5.0.27]# make
          出现错误:
          /usr/bin/ld: attempted static link of dynamic object `/usr/lib/libncurses.so.5'
          collect2: ld returned 1 exit status
          make[2]: *** [mysql] 错误 1
          make[2]: Leaving directory `/home/navy/Desktop/mysql-5.0.27/client'
          make[1]: *** [all-recursive] 错误 1
          make[1]: Leaving directory `/home/navy/Desktop/mysql-5.0.27'
          make: *** [all] 错误 2
          解决方法:
          检查是否已经安装以下的辅助软件包
          [root@localhost mysql-5.0.27]# rpm -q ncurses
          ncurses-5.5-24.
          [root@localhost mysql-5.0.27]# rpm -q ncurses-devel
          package ncurses-devel is not installed
          提示ncurses-devel没有安装,用yum安装:
          [root@localhost mysql-5.0.27]# yum install ncurses-devel
          Setting up Install Process
          Total download size: 1.6 M
          Is this ok [y/N]: y
          Downloading Packages:
          Installed:  ncurses-devel.i386 0:5.5-24.
          Complete!
          ---
          重新configure,make时再次出现错误:
          /usr/bin/ld: attempted static link of dynamic object `/usr/lib/libncurses.so.5'
          collect2: ld returned 1 exit status
          make[2]: *** [mysql] 错误 1
          make[2]: Leaving directory `/home/navy/Desktop/mysql-5.0.27/client'
          make[1]: *** [all-recursive] 错误 1
          make[1]: Leaving directory `/home/navy/Desktop/mysql-5.0.27'
          make: *** [all] 错误 2
          解决方法:
          在configure时将选项“--with-named-curses-libs=/usr/lib/libncurses.so.5”去除
          # ./configure --prefix=/program/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=gbk --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --with-charset=utf8
          [root@localhost mysql-5.0.27]# make
          make成功!
          [root@localhost mysql-5.0.27]# make install
          ---
          [root@localhost mysql-5.0.27]# useradd mysql //添加 mysql 用户
          [root@localhost mysql-5.0.27]# cd /program/mysql/
          [root@localhost mysql]# bin/mysql_install_db --user=mysql
          Installing all prepared tables
          [root@localhost mysql]# chown -R root:mysql . //设置权限,注意后面有一个 "."
          [root@localhost mysql]# chown -R mysql /var/lib/mysql //设置 mysql 目录权限
          [root@localhost mysql]# chgrp -R mysql . //注意后面有一个 "."
          [root@localhost mysql]# cp share/mysql/my-huge.cnf /etc/my.cnf
          cp:是否覆盖“/etc/my.cnf”? y
          [root@localhost mysql]# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld//开机自动启动 mysql
          cp:是否覆盖“/etc/rc.d/init.d/mysqld”? y
          [root@localhost mysql]# chkconfig --add mysqld
          [root@localhost mysql]# /etc/rc.d/init.d/mysqld start//启动 MySQL
          Starting MySQL
          [root@localhost mysql]# bin/mysqladmin -u root password "要设置的密码"
          [root@localhost mysql]# service mysqld stop//关闭 MySQL
          Shutting down MySQL
          ---
          统一编码
          1.2.1首先要确保centos5以中文方式安装,我测试过先按英文方式安装,可后来怎么也配不上中文字符集。重新用中文方式安装,字符集都会自动加载了,免去很多烦恼。
          如果不放心,确认一下:
          vi /etc/sysconfig/i18n (确保其内容是这样的.)
          LANG="zh_CN.UTF-8"
          查看变量:env
          export  LANG=zh_CN.UTF-8
          如果都是这样,就正确了!
          1.2.2修改mysql的配置文件,使数据库与服务器操作系统的字符集设置一致。
          vi /etc/my.cnf 设置(如果没有发现这个文件,就新建1个)
          [mysqld]
          datadir=/var/lib/mysql
          socket=/var/lib/mysql/mysql.sock
          default-character-set=utf8  (增加的关键一句,使得数据库缺省以utf8存储)
          当然,修改后,要重启数据库。
          再次用mysql -u root -p命令进入数据库系统,用SHOW VARIABLES LIKE 'character_set_%';命令查看到如下内容:
          +--------------------------+---------------------- ----------------+
          | Variable_name            | Value                                |
          +--------------------------+---------------------- ----------------+
          | character_set_client     | latin1                               |
          | character_set_connection | latin1                               |
          | character_set_database   | utf8                                 |
          | character_set_filesystem | binary                               |
          | character_set_results    | latin1                               |
          | character_set_server     | utf8                                 |
          | character_set_system     | utf8                                 |
          | character_sets_dir       | /program/mysql/share/mysql/charsets/ |
          +--------------------------+---------------------- ----------------+
          但这样还不够,还要保证客户端也是用utf8的字符集来操作的。
          登录的时候,要用以下命令:mysql --default-character-set=utf8 -u root -p
          再次用SHOW VARIABLES LIKE 'character_set_%';命令查看,结果变成了:
          mysql> SHOW VARIABLES LIKE 'character_set_%';
          +--------------------------+---------------------- ----------------+
          | Variable_name            | Value                                |
          +--------------------------+---------------------- ----------------+
          | character_set_client     | utf8                                 |
          | character_set_connection | utf8                                 |
          | character_set_database   | utf8                                 |
          | character_set_filesystem | binary                               |
          | character_set_results    | utf8                                 |
          | character_set_server     | utf8                                 |
          | character_set_system     | utf8                                 |
          | character_sets_dir       | /program/mysql/share/mysql/charsets/ |
          +--------------------------+---------------------- ----------------+
          也可以用set改变编码,不过退出sql后,不能保存。
          set character_set_client=utf8;
          ---
          参考文章


http://forum.lupaworld.com/thread-59469-1-1.html

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
11月前
|
搜索推荐 5G 网络性能优化
|
机器学习/深度学习 缓存 PyTorch
PyTorch 2.0 推理速度测试:与 TensorRT 、ONNX Runtime 进行对比
PyTorch 2.0 于 2022 年 12 月上旬在 NeurIPS 2022 上发布,它新增的 torch.compile 组件引起了广泛关注,因为该组件声称比 PyTorch 的先前版本带来更大的计算速度提升。
1133 0
|
消息中间件 算法 Java
2023金九银十Java高级工程师面试 1000 题+答案(全)
前言 春节过后招聘旺季就到了,不知道大家是否准备好了,面对金三银四的招聘旺季,如果没有精心准备那笔者认为那是对自己不负责任;就我们 Java 程序员来说,多数的公司总体上面试都是以自我介绍+项目介绍+项目细节/难点提问+基础知识点考核+算法题这个流程下来的。 有些公司可能还会问几个实际的场景类的问题,这个环节阿里是必问的,这种问题通常是没有正确答案的,就看个人的理解,个人的积累了。剩下的就没啥了,都是换汤不换药,聊项目就看你自己对你自己的项目是否理解的透彻,比如经常问你你为什么选择这个技术,为什么这么处理之类的,常考的基础的知识点就那么多,最后算法就是靠刷题。 今天为大家分享的就是当前
|
安全 物联网 网络安全
|
机器学习/深度学习 人工智能 算法
探索软件测试中的AI应用
【6月更文挑战第6天】随着人工智能的不断进步,它在软件测试领域的应用也日益广泛。本文将深入探讨AI在软件测试中的角色,以及如何利用这些技术提升测试效率和质量。通过具体案例分析,我们将揭示AI技术如何帮助测试人员更快地识别缺陷,预测潜在的错误,并提供自动化测试解决方案。
|
安全 网络协议 网络安全
【Python】已解决:pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool (host=’ files. pyth
【Python】已解决:pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool (host=’ files. pyth
1913 0
|
存储 算法 安全
C++中文件路径的存储类型:不同类型的选择和应用场景
C++中文件路径的存储类型:不同类型的选择和应用场景
225 0
|
缓存 JavaScript 前端开发
Vue指令之战:v-if vs. v-show -你应该使用哪一个?
Vue指令之战:v-if vs. v-show -你应该使用哪一个?
385 0
|
编解码 安全 Linux
Linux vs windows 他们之间的区别
Linux vs windows 他们之间的区别
537 0
|
前端开发
若依修改,配置了一个接口路径出现了,如何放通接口{ “msg“: “请求访问:/code/list,认证失败,无法访问系统资源“, “code“: 401}
若依修改,配置了一个接口路径出现了,如何放通接口{ “msg“: “请求访问:/code/list,认证失败,无法访问系统资源“, “code“: 401}