1、准备工作

其官方站点为http://www.mysql.com/

  • 为了避免发生端口冲突、程序冲突现象、建议先查询MySQL软件的安装情况,确认没有使用以RPM方式安装的mysql-server、mysql软件包、建议将其卸载
[root@www /]# rpm -q mysql-server mysql
package mysql-server is not installed
package mysql is not installed
[root@www /]# yum -y install ncurses-devel
  • MySQl5.5需要cmake编译安装、先安装cmake包
[root@www cmake-2.8.]# yum -y install gcc gcc*
[root@www cmake-2.8.]# tar zxf cmake-2.8..tar.gz
[root@www cmake-2.8.]# cd cmake-2.8.
[root@www cmake-2.8.]# ./configure
[root@www cmake-2.8.]# gmake && gmake install

2、源码编译安装

  • 创建运行用户
[root@www cmake-2.8.]# groupadd mysql
[root@www cmake-2.8.]# useradd -M -s /sbin/nologin mysql -g mysql
  • 解压
[root@www /]# tar zxf mysql-5.5..tar.gz
[root@www /]# cd mysql-5.5.
  • 配置
[root@www mysql-5.5.]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all 

 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql   :指定mysql数据库程序安装目录
-DSYSCONFDIR=/etc :指定初始化参数文件目录
-DDEFAULT_CHARSET=utf8 :指定默认使用的字符集校队规则
-DDEFAULT_COLLATION=utf8_general_ci :是适用UTF-8字符集的通用规则
-DWITH_EXTRA_CHARSETS=all :指定额外支持的其他字符集编码 -- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /mysql-5.5. [root@www mysql-5.5.]# yum -y install bison
[root@www mysql-5.5.]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -- Configuring done
-- Generating done
-- Build files have been written to: /mysql-5.5.
[root@www mysql-5.5.]# echo $?
  • 编译并安装
[root@www mysql-5.5.]# make && make install
[root@www mysql-5.5.]# echo $?
  • 对数据库目录进行权限设置
[root@www mysql-5.5.]# chown -R mysql:mysql /usr/local/mysql/
  • 建立配置文件

在MySQL源码目录中的support-files 文件夹下,提供了适合不同负载数据库的样本配置文件,如果不确定数据库系统的应用规模,一般选择ny-medium.cnf文件即可,该文件能够满足大多数企业的中等应用需求。

[root@www mysql-5.5.]# rm -rf /etc/my.cnf
[root@www mysql-5.5.]# cp support-files/my-medium.cnf /etc/my.cnf
  • 初始化数据库
[root@www mysql-5.5.]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
  • 设置环境变量
[root@www mysql-5.5.]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@www mysql-5.5.]# . /etc/profile
  • 添加系统服务
[root@www mysql-5.5.]# cp support-files/mysql.server /etc/init.d/mysqld
[root@www mysql-5.5.]# chmod +x /etc/rc.d/init.d/mysqld
[root@www mysql-5.5.]# chkconfig --add mysqld
[root@www mysql-5.5.]# /etc/init.d/mysqld start
Starting MySQL.... SUCCESS!
[root@www mysql-5.5.]# /etc/init.d/mysqld status
SUCCESS! MySQL running ()
[root@www mysql-5.5.]# netstat -anpt | grep mysqld
tcp 0.0.0.0: 0.0.0.0:* LISTEN /mysqld
  • 访问数据库

  进过安装后的初始化过程,MySQL数据库的默认管理员用户名为"root",密码为空。若要以未设置密码的root用户登录本机的MySQL数据库,可以执行一下操作。

[root@localhost /]# mysql -u root   //"-u"选项用于指定认证用户
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. Source distribution Copyright (c) , , 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>

在有密码的情况下,还应使用"-p"选项进行密码效验

[root@localhost /]# mysql -u root -p
Enter password: //根据提示输入正确密码

最新文章

  1. Alwayson--SYS.dm_hadr_instance_node_map 返回0行
  2. linux中级-JAVA企业级应用TOMCAT实战
  3. Apache Spark技术实战之3 -- Spark Cassandra Connector的安装和使用
  4. java集合 之 set 集合
  5. python3.5在print和input上的几个变化
  6. 非常非常好!写了好久 k-th-smallest-in-lexicographical-order
  7. mysql开启外联方法
  8. PHP获取IP地址所在的地理位置
  9. 使用Unidac内置连接池
  10. codeforces 149E . Martian Strings kmp
  11. 异步工作流控制-condCall
  12. docker~为什么没人说说.dockerignore
  13. jquery模板下载网站
  14. Scala - 快速学习04 - 求值策略
  15. servlet篇 之 servlet的访问
  16. kudu的写数据流程
  17. [codechef]SnackDown 2017 Online Elimination Round Prefix XOR
  18. 一个nginx 回源限速的bug处理过程记录
  19. Netty 发送消息失败或者接收消息失败的可能原因
  20. [转帖]super-inspire

热门文章

  1. CF570D:Tree Requests
  2. JS-计算器制作
  3. CSS3-box盒布局
  4. 通过Nginx,Tomcat访问日志(access log)记录请求耗时
  5. GitHub官方介绍(中文翻译)
  6. Oracle创建表空间及用户
  7. Runner站立会议07
  8. 20145212《Java程序程序设计》课程总结
  9. yum安装指定(特定)版本(旧版本)软件包的方法
  10. FPM打包工具