首先去官网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
Whether to use the readline
library bundled with the distribution.
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
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://www.cnblogs.com/youxin/p/5087041.html