fedora 20 源码编译安装 mysql-5.6.15

fedora 20 源码编译安装 mysql-5.6.15

我的是fedora 20, 64位的系统.安装的是mysql的最新版本, mysql-5.6.15.

http://dev.mysql.com/downloads/mysql/  这是mysql的官方下载地址, 需要一个注册账号.


这是官方的安装说明.

# Preconfiguration setup
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
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

我就是按照这说明安装成功的.

1. 解压缩下载的源码包 mysql-5.6.15.tar.gz

tar zxvf mysql-5.6.15.tar.gz

2. 配置编译

设置编译优化参数

export CFLAGS="-O2 -mtune=native -march=native"

export CXXFLAGS="-O2 -mtune=native -march=native"

这是针对本机进行的优化,不保证可移植性, 如果想可移植打包供其他主机使用,不要添加这写选项.光用一个O2即可.

mysql 依赖 ncurses 库,没安装的需要安装一下,

yum install ncurses-devel

cd 进入到源码的解压目录开始配置

cmake .  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \                                   //安装目录
-DMYSQL_DATADIR=/usr/local/mysql/data \                                         //数据目录
-DSYSCONFDIR=/etc \                                                                              //配置文件 my.cnf 的目录
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock                            //mysql.sock 目录

更多参数可一去参考官方的文档说明: http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

完后没错误的就可以 make, sudo make install.

3.安装完需要设置一下才可启动

添加 mysql 组和 mysql 用户:

[like@bogon mysql]$sudo groupadd mysql

[like@bogon mysql]$sudo useradd -r -g mysql mysql

进入到mysql的安装目录 更改目录为mysql 所有,组也为mysql.

[like@bogon mysql]$ sudo chown -R mysql .
[like@bogon mysql]$ sudo chgrp -R mysql .

初始化数据

[like@bogon mysql]$ sudo scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data

[like@bogon mysql]$  sudo scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2014-01-19 20:11:12 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-19 20:11:12 19967 [Note] InnoDB: The InnoDB memory heap is disabled
2014-01-19 20:11:12 19967 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-01-19 20:11:12 19967 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-01-19 20:11:12 19967 [Note] InnoDB: Using Linux native AIO
2014-01-19 20:11:12 19967 [Note] InnoDB: Using CPU crc32 instructions
2014-01-19 20:11:12 19967 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-01-19 20:11:12 19967 [Note] InnoDB: Completed initialization of buffer pool
2014-01-19 20:11:12 19967 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-01-19 20:11:12 19967 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-01-19 20:11:12 19967 [Note] InnoDB: Database physically writes the file full: wait...
2014-01-19 20:11:12 19967 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-01-19 20:11:12 19967 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-01-19 20:11:13 19967 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-01-19 20:11:13 19967 [Warning] InnoDB: New log files created, LSN=45781
2014-01-19 20:11:13 19967 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-01-19 20:11:13 19967 [Note] InnoDB: Doublewrite buffer created
2014-01-19 20:11:13 19967 [Note] InnoDB: 128 rollback segment(s) are active.
2014-01-19 20:11:13 19967 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-01-19 20:11:13 19967 [Note] InnoDB: Foreign key constraint system tables created
2014-01-19 20:11:13 19967 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-01-19 20:11:13 19967 [Note] InnoDB: Tablespace and datafile system tables created.
2014-01-19 20:11:13 19967 [Note] InnoDB: Waiting for purge to start
2014-01-19 20:11:13 19967 [Note] InnoDB: 5.6.15 started; log sequence number 0
2014-01-19 20:11:16 19967 [Note] Binlog end
2014-01-19 20:11:16 19967 [Note] InnoDB: FTS optimize thread exiting.
2014-01-19 20:11:16 19967 [Note] InnoDB: Starting shutdown...
2014-01-19 20:11:17 19967 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-01-19 20:11:17 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-19 20:11:17 19990 [Note] InnoDB: The InnoDB memory heap is disabled
2014-01-19 20:11:17 19990 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-01-19 20:11:17 19990 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-01-19 20:11:17 19990 [Note] InnoDB: Using Linux native AIO
2014-01-19 20:11:17 19990 [Note] InnoDB: Using CPU crc32 instructions
2014-01-19 20:11:17 19990 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-01-19 20:11:17 19990 [Note] InnoDB: Completed initialization of buffer pool
2014-01-19 20:11:17 19990 [Note] InnoDB: Highest supported file format is Barracuda.
2014-01-19 20:11:17 19990 [Note] InnoDB: 128 rollback segment(s) are active.
2014-01-19 20:11:17 19990 [Note] InnoDB: Waiting for purge to start
2014-01-19 20:11:18 19990 [Note] InnoDB: 5.6.15 started; log sequence number 1625977
2014-01-19 20:11:18 19990 [Note] Binlog end
2014-01-19 20:11:18 19990 [Note] InnoDB: FTS optimize thread exiting.
2014-01-19 20:11:18 19990 [Note] InnoDB: Starting shutdown...
2014-01-19 20:11:19 19990 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

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:

  ./bin/mysqladmin -u root password 'new-password'
  ./bin/mysqladmin -u root -h bogon password 'new-password'

Alternatively you can run:

  ./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 . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

更改数据文件夹所有者和组为mysql

[like@bogon mysql]$ sudo chown -R root .
[like@bogon mysql]$ sudo chown -R mysql data

然后就可以启动mysql数据库了.

sudo support-files/mysql.server start

成功启动如下所示:

[kuaile@localhost mysql]$ sudo support-files/mysql.server start
Starting MySQL.                                            [  确定  ]

把 mysql.server 复制到系统相应的目录即可开机自动启动mysql.

cp support-files/mysql.server /etc/init.d/mysql.server

4. 安装完成后mysql数据库的root用户是没密码的,需要自己设置密码.

  ./bin/mysqladmin -u root password 'new-password'                                     //用于本机执行

  ./bin/mysqladmin -u root -h bogon password 'new-password'                   //非本机


这俩个成功一个即可.

new-password 就是新密码.

然后就可以用这个新密码连接mysql数据库了


mysql 自带安全设置.

运行这个命令

sudo ./bin/mysql_secure_installation

根据提示回答 yes or no 完成安全设置

 sudo ./bin/mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] n
 ... skipping.

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...


你可能感兴趣的:(fedora 20 源码编译安装 mysql-5.6.15)