从MySQL5.5 开始就要用cmake安装,本次安装的版本为mysql-5.5.22.tar.gz

#准备工作
yum install -y gcc gcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-devel cmake bison #添加mysql用户、组
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql/ #创建mysql安装目录
mkdir /data/mysql #创建数据存放目录 #配置编译安装mysql
tar zxvf mysql-5.5..tar.gz
cd mysql-5.5.
cmake . \ #开始编译
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装到/usr/local/mysql目录
-DMYSQL_DATADIR=/data/mysql \ #数据存放到/data/mysql目录
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \ #sock存放到/data/mysql目录
-DWITH_INNOBASE_STORAGE_ENGINE= \ #innoDB引擎
-DENABLED_LOCAL_INFILE= \
-DDEFAULT_CHARSET=utf8 \ #字符集
-DDEFALUT_CHARSETS=all \ #支持所有字符集
-DWITH_BLACKHOLE_STORAGE_ENGINE= \
-DWITH_ARCHIVE_STORAGE_ENGINE= \
-DWITH_PARTITION_STORAGE_ENGINE= \
-DDEFAULT_COLLATION=utf8_general_ci \ #字符集校验
-DMYSQL_USER=mysql \
-DEXTRA_CHARSETS=all \
-DMYSQL_TCP_PORT= \
-DWITH_DEBUG=\ make
make install #改变目录权限
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql chown -R mysql /data/mysql
chgrp -R mysql /data/mysql scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --ldata=/data/mysql #初始化数据库 chown -R root /usr/local/mysql #可选
cp support-files/my-medium.cnf /etc/my.cnf #复制配置文件 cp support-files/mysql.server /etc/init.d/mysqld #复制启动脚本
chmod /etc/init.d/mysqld #将mysql的启动服务添加到系统服务中
chkconfig --add mysqld #添加系统服务
chkconfig mysqld on #添加开机启动
chkconfig --levels mysqld off

echo "/usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/data/mysql/ &" >> /etc/rc.loacl export PATH=$PATH:/usr/local/mysql/bin #添加环境变量
echo 'PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile #启动mysql
service mysqld start/stop

/usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/data/mysql/ & 适用于没有自启动文件的 #启动mysql,看是否成功
netstat -tnl|grep

手册中提到的安装方法:

  

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: /usr/local/mysql//bin/mysqladmin -u root password 'new-password'
/usr/local/mysql//bin/mysqladmin -u root -h localhost password 'new-password' Alternatively you can run:
/usr/local/mysql//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. You can start the MySQL daemon with:
cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!

默认的mysql安装目录

  

shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

修改默认密码(默认无密码):

    use mysql;
update user set password=password('') where user='root'
flush privileges;

安装过程中的一些说明

  

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: /usr/local/mysql//bin/mysqladmin -u root password 'new-password'
/usr/local/mysql//bin/mysqladmin -u root -h localhost password 'new-password' Alternatively you can run:
/usr/local/mysql//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. You can start the MySQL daemon with:
cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!
#mysql 默认读取配置文件 顺序
/etc/my.cnf ~/.my.cnf /usr/local/mysql/etc/my.cnf
#查看编译参数
sudo cat /usr/local/mysql/bin/mysqlbug|grep configure

 提示mysql.sock找不到的解决

原因:

当php连接mysql时如果是本地连接(127.0.0.1 或 localhost )时,会用到 pdo_mysql.default_socket= 参数(如果是pdo连接数据库),
该默认参数为 pdo扩展编译时的参数

[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000 ; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=

参考文章地址:

http://wowking.blog.51cto.com/1638252/1037609

http://blog.csdn.net/westmaniac/article/details/6535000

  

mysql 5.5安装手记的更多相关文章

  1. Windows下php,mysql,apache相关安装与配置,完善中…

    PHP 的安装 由于php是一个zip文件(非install版),安装较为简单解压就行.把解压的 php5.2.1-Win32重命名为 php5.并复制到安装盘目录下.例如安装路径为 c:\php5 ...

  2. mysql 7下载安装及问题解决

    mysql 7安装及问题解决 一.mysql下载 下载地址:https://www.mysql.com/downloads/ Community (GPL) Downloads MySQL Commu ...

  3. SQL Server 2016 CTP2.2 安装手记

    SQL Server 2016 CTP2.2 安装手记 下载一个iso文件,解压出来(大约2.8G左右),在该路径下双击Setup.exe即可开始安装. 安装之前请先安装.NET 3.5 SP1,在服 ...

  4. MySQL数据库的安装与密码配置

                      MySQL是由MySQL AB公司开发,后由Oracle公司收购     MySQL是一个关系型数据库管理系统       分为社区版和企业版            ...

  5. my SQL下载安装,环境配置,以及密码忘记的解决,以及navicat for mysql下载,安装,测试连接

    一.下载 在百度上搜索"mysql-5.6.24-winx64下载" 二.安装 选择安装路径,我的路径“C:\Soft\mysql-5.6.24-winx64” 三.环境配置 计算 ...

  6. mysql安装和mysql图形界面安装以及文本文件导入mysql

    本人大一大二一直使用windows系统,被微软爸爸给惯坏了,一看到cmd命令行就吓尿.现在用ubuntu,每一个操作都是语句,也是得到锻炼(个jb). ubuntu安装mysql和python代码 s ...

  7. MySQL下载、安装及启动

    介绍 Mysql是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Database Management System:关系数据库管理系统)应用软件之 ...

  8. Windows下MySQL 5.6安装及配置详细图解

    一.安装前的准备 1.下载安装程序包,可到MySQL官方网站http://www.mysql.com/下载,如图1-1: 图1-1 下载后的安装文件如图1-2所示: 图1-2 二.安装 1.双击下载的 ...

  9. CentOS6.0(64位)安装Apache+PHP+Mysql教程,安装Magento(解决DOM,Mcrypt,GD问题)完整教程

    CentOS6.0(64位)安装Apache+PHP+Mysql教程,安装Magento(解决DOM,Mcrypt,GD问题)完整教程 0   Posted by :小黑 On : 2012 年 9 ...

随机推荐

  1. JDK源码(1.7) -- java.util.ListIterator<E>

    java.util.ListIterator<E> 源码分析(JDK1.7) ------------------------------------------------------- ...

  2. 安装myeclipse的常见问题

    1.破解myeclipse网站:  https://jingyan.baidu.com/article/acf728fd49519ff8e410a361.html 

  3. python开发_pprint()

    python中的pprint.pprint(),类似于print() 下面是我做的demo: #python pprint '''python API中提供的Sample''' import json ...

  4. Unity创建asset文件的扩展编辑器

    using UnityEngine; using UnityEditor; using System.IO; public class CreateAsset : EditorWindow { pri ...

  5. 线程,线程安全与python的GIL锁

    今天看到一篇文章,讲述的是几个提升python性能的项目:传送门 在看的过程中,接触到一个名词,一个从学python开始就一直看到,但是从来都是一知半解的名词,心里不开心,必须把它搞明白,对了,这个词 ...

  6. ExifInterface针对照片的使用

    ExifInterface是保存照片信息的,那么我们在有需要的时候就可以通过这类,来获取照片的一些数码参数来做适当来逻辑处理,比较典型的案例就是android有的机型拍照或者选择照片后,照片可能会被旋 ...

  7. Markdown 简明语法手册 - 作业

    目录 Cmd Markdown 简明语法手册 1. 内容目录 2. 标签分类 3. 删除线 水平线--- 1. 斜体和粗体 2. 分级标题 标题1 标题2 标题3 3. 外链接 4. 无序列表 5. ...

  8. Java代码优化方案 J2ME内存优化

    Java代码优化方案 J2ME内存优化 从几本书上,N个网站上整理的一些JAVA代码优化方案,最近的项目只有1M内存可用,必须很抠门了~J2ME项目更要注意的 避免内存溢出 l 不用的对象释放(置空) ...

  9. 后端程序员写的前端js代码模板

    看几天的javascript面向对象和基础等之类相关javascript的知识,因为自己是写php的,也写过java,所以想在写javascript代码的时候也能用上面向对象的思想, 折腾了一整天的j ...

  10. mount umont

    如果想在运行的Linux下访问其它文件系统中的资源的话,就要用mount命令来实现. 2.      mount的基本用法是?格式:mount [-参数] [设备名称] [挂载点] 其中常用的参数有: ...