首页 > 代码库 > linux下MySQL 5.6源码安装
linux下MySQL 5.6源码安装
linux下MySQL 5.6源码安装
1、下载:当前mysql版本到了5.6.20
http://dev.mysql.com/downloads/mysql
选择Source Code
2、必要软件包
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
3、编译安装
添加用户
groupadd mysqluseradd -r -g mysql mysql
编译安装
tar -zxvf mysql-5.6.20.tar.gzcd mysql-5.6.20 #默认情况下是安装在/usr/local/mysqlcmake .make && make install
编译参数
cmake -DCMAKE_INSTALL_PREFIX=/alidata/server/mysql-5.6.20 -DMYSQL_DATADIR=/alidata/server/mysql-5.6.20/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/alidata/server/mysql-5.6.20/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci ;
编译的参数可以参考http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
有时候会出现类似的问题。
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl-- Configuring done-- Generating done
- 使用参数-DENABLE_DOWNLOADS=1 自动下载。
- 有网络限制,设置http代理
export http_proxy=http://example.com:80
。环境变量http_proxy
也为 curl 等其他工具所用。尽管 yum 可以识别大写或小写的 http_proxy,但curl 要求环境变量的名称是小写。
如果这个cmake这个步骤有出现问题,解决后重新再cmake一次。如果输出类似这样,那么就好了。
-- Running cmake version 2.6.4-- MySQL 5.6.20-- Packaging as: mysql-5.6.20-Linux-x86_64-- HAVE_VISIBILITY_HIDDEN-- HAVE_VISIBILITY_HIDDEN-- HAVE_VISIBILITY_HIDDEN-- Using cmake version 2.6.4-- Not building NDB-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl-- Configuring done-- Generating done-- Build files have been written to: /root/tools/mysql-5.6.20
接着编译源码
make && make install
改变目录所有者
chown mysql:mysql /alidata/server/mysql-5.6.20/
4、初始化数据库
cd /alidata/server/mysql-5.6.20/scripts./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/data
5、注册为服务
cd /alidata/server/mysql-5.6.20/support-files #注册服务cp mysql.server /etc/rc.d/init.d/mysql #使用默认配置文件cp ../my.cnf /etc/my.cnf#修改配置文件basedir=/alidata/server/mysql-5.6.20datadir=/alidata/server/mysql-5.6.20/data #让chkconfig管理mysql服务chkconfig --add mysql #开机启动chkconfig mysql on
6、启动MySQL服务
service mysql start
7、改变编码,防止乱码
SHOW VARIABLES LIKE ‘character%‘
修改mysql的my.cnf文件
[client]default-character-set=utf8 [mysqld]character-set-server=utf8 [mysql]default-character-set=utf8
8、将mysql的bin加入到path中
cd ~#我把path添加到当前用户目录的bashrc中,如果需要全局设定,请修改`/etc/profile`vi .bashrc #加入以下内容PATH=/alidata/server/mysql-5.6.20/bin:$PATHexport PATH
9、配置用户密码和远程访问权限
mysql -uroot SET PASSWORD = PASSWORD(‘123456‘); GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
部分步骤debug 如下:
./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/data
[root@iZ23lt92evyZ scripts]# ./mysql_install_db --user=mysql --basedir=/alidata/server/mysql-5.6.20 --datadir=/alidata/server/mysql-5.6.20/dataInstalling MySQL system tables...2014-09-30 20:42:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2014-09-30 20:42:53 19761 [Note] InnoDB: Using atomics to ref count buffer pool pages2014-09-30 20:42:53 19761 [Note] InnoDB: The InnoDB memory heap is disabled2014-09-30 20:42:53 19761 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2014-09-30 20:42:53 19761 [Note] InnoDB: Memory barrier is not used2014-09-30 20:42:53 19761 [Note] InnoDB: Compressed tables use zlib 1.2.32014-09-30 20:42:53 19761 [Note] InnoDB: Using CPU crc32 instructions2014-09-30 20:42:53 19761 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-09-30 20:42:53 19761 [Note] InnoDB: Completed initialization of buffer pool2014-09-30 20:42:53 19761 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2014-09-30 20:42:53 19761 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2014-09-30 20:42:53 19761 [Note] InnoDB: Database physically writes the file full: wait...2014-09-30 20:42:53 19761 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2014-09-30 20:42:54 19761 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2014-09-30 20:42:55 19761 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02014-09-30 20:42:55 19761 [Warning] InnoDB: New log files created, LSN=457812014-09-30 20:42:55 19761 [Note] InnoDB: Doublewrite buffer not found: creating new2014-09-30 20:42:55 19761 [Note] InnoDB: Doublewrite buffer created2014-09-30 20:42:55 19761 [Note] InnoDB: 128 rollback segment(s) are active.2014-09-30 20:42:55 19761 [Warning] InnoDB: Creating foreign key constraint system tables.2014-09-30 20:42:55 19761 [Note] InnoDB: Foreign key constraint system tables created2014-09-30 20:42:55 19761 [Note] InnoDB: Creating tablespace and datafile system tables.2014-09-30 20:42:55 19761 [Note] InnoDB: Tablespace and datafile system tables created.2014-09-30 20:42:55 19761 [Note] InnoDB: Waiting for purge to start2014-09-30 20:42:55 19761 [Note] InnoDB: 5.6.20 started; log sequence number 02014-09-30 20:42:56 19761 [Note] Binlog end2014-09-30 20:42:56 19761 [Note] InnoDB: FTS optimize thread exiting.2014-09-30 20:42:56 19761 [Note] InnoDB: Starting shutdown...2014-09-30 20:42:57 19761 [Note] InnoDB: Shutdown completed; log sequence number 1625977OKFilling help tables...2014-09-30 20:42:57 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2014-09-30 20:42:57 19783 [Note] InnoDB: Using atomics to ref count buffer pool pages2014-09-30 20:42:57 19783 [Note] InnoDB: The InnoDB memory heap is disabled2014-09-30 20:42:57 19783 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2014-09-30 20:42:57 19783 [Note] InnoDB: Memory barrier is not used2014-09-30 20:42:57 19783 [Note] InnoDB: Compressed tables use zlib 1.2.32014-09-30 20:42:57 19783 [Note] InnoDB: Using CPU crc32 instructions2014-09-30 20:42:57 19783 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-09-30 20:42:57 19783 [Note] InnoDB: Completed initialization of buffer pool2014-09-30 20:42:57 19783 [Note] InnoDB: Highest supported file format is Barracuda.2014-09-30 20:42:57 19783 [Note] InnoDB: 128 rollback segment(s) are active.2014-09-30 20:42:57 19783 [Note] InnoDB: Waiting for purge to start2014-09-30 20:42:57 19783 [Note] InnoDB: 5.6.20 started; log sequence number 16259772014-09-30 20:42:57 19783 [Note] Binlog end2014-09-30 20:42:57 19783 [Note] InnoDB: FTS optimize thread exiting.2014-09-30 20:42:57 19783 [Note] InnoDB: Starting shutdown...2014-09-30 20:42:58 19783 [Note] InnoDB: Shutdown completed; log sequence number 1625987OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands: /alidata/server/mysql-5.6.20/bin/mysqladmin -u root password ‘new-password‘ /alidata/server/mysql-5.6.20/bin/mysqladmin -u root -h iZ23lt92evyZ password ‘new-password‘Alternatively you can run: /alidata/server/mysql-5.6.20/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with: cd . ; /alidata/server/mysql-5.6.20/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.plPlease report any problems at http://bugs.mysql.com/The latest information about MySQL is available on the web at http://www.mysql.comSupport MySQL by buying support/licenses at http://shop.mysql.comNew default config file was created as /alidata/server/mysql-5.6.20/my.cnf andwill be used by default by the server when you start it.You may edit this file to change server settings
参考:
http://blog.163.com/liyinhui20080527@126/blog/static/815232582013885310900/
http://www.cnblogs.com/xiongpq/p/3384681.html
转自: http://my.oschina.net/looly/blog/297980#OSC_h2_1
linux下MySQL 5.6源码安装
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。