首页 > 数据库技术 > 详细

mysql源码编译安装

时间:2015-12-29 22:28:39      阅读:253      评论:0      收藏:0      [点我收藏+]

首先去官网http://dev.mysql.com/downloads/mysql/ 下载mysql源码。我下的是5.7.10

mysql依赖boost,要安装boost

官方的安装文档:http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html,官方文档说大概如下:

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false 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

 

linux mysql默认安装路径

Installations created from Linux RPM distributions result in files under the following system directories:
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
/usr/lib/mysql
/usr/include/mysql
/usr/share/mysql
/usr/bin/mysql

编译安装:

sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DWITH_DEBUG=0

 

    1. sudo make -j4 #-j 数字 表示以多核心运行
    2. sudo make install

 -DWITH_READLINE=bool

Whether to use the readline library bundled with the distribution.

 -DENABLED_LOCAL_INFILE=bool

Whether to enable LOCAL capability in the client library for LOAD DATA INFILE.

This option controls client-side LOCAL capability, but the capability can be set on the server side at server startup with the --local-infile option. See Section 6.1.6, “Security Issues with LOAD DATA LOCAL”.

 

配置选项:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

4.相关设置

4.1配置开机启动
  1. sudo cp ./support-files/my-default.cnf /etc/my.cnf
  2. sudo cp ./support-files/mysql.server  /etc/init.d/mysqld  #把Mysql加入系统启动
  3. sudo chmod 755 /etc/init.d/mysqld
  4. sudo chkconfig mysqld on
4.2常用命令软连接
  1. sudo ln -s /usr/local/mysql/bin/mysql /usr/bin
  2. sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
4.3 初始化数据库
  1. sudo /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --skip-name-resolve --user=mysql
4.4 修改配置文件
  1. sudo vi /etc/my.cnf
文件末尾增加:
  1. #增加默认存储类型和去掉反向解析
  2. default-storage-engine=MyISAM
  3. skip-name-resolve
如果出现The server quit without updating PID file,请根据创建pid并更改权限775
 

6)配置环境变量
为了直接调用mysql,需要将mysql的bin目录加入PATH环境变量。
编辑/etc/profile文件:
sudo vim /etc/profile
在文件最后 添加如下两行:
PATH=$PATH:/usr/local/mysql/bin
export PATH
关闭文件,运行下面的命令,让配置立即生效:
source /etc/profile


(7)修改root密码(因为默认密码为空)
mysql -h127.0.0.1 -uroot -p
update mysql.user set password=password("mysqldba") where user=‘root‘;
flush privileges;


测试一下:

select now(),user(),version();
show databases;

参考:
http://yanue.net/post-111.html

mysql源码编译安装

原文:http://www.cnblogs.com/youxin/p/5087041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!