CentOS下安装mysql

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 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

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
关系型数据库 MySQL Linux
centos7.0环境下安装MySql_8.0.12
centos7.0环境下安装MySql_8.0.12
|
2月前
|
缓存 关系型数据库 MySQL
百度搜索:蓝易云【CentOS8服务器安装MySQL报错:no match mysql-community-server】
现在,你已经成功安装了MySQL服务器并解决了"no match mysql-community-server"的报错问题。祝你使用愉快!
42 1
|
3月前
|
关系型数据库 MySQL Unix
CentOS安装MySQL5.5
CentOS安装MySQL5.5
82 0
|
2月前
|
关系型数据库 MySQL Linux
CentOS7环境下安装MySQL5.6
CentOS7环境下安装MySQL5.6
195 0
|
9天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
17 0
|
1月前
|
分布式计算 关系型数据库 MySQL
Sqoop【部署 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
【2月更文挑战第8天】Sqoop CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
93 1
|
3天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
32 2
|
9天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
46 0
|
1月前
|
关系型数据库 MySQL Linux
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
178 0
|
2月前
|
NoSQL 应用服务中间件 Linux
CentOS7搭建MySQL+Redis+MongoDB+FastDF
CentOS7搭建MySQL+Redis+MongoDB+FastDF
138 0