天天看点

MySQL-5.6.x二进制版本安装记录

一、操作系统安装环境

1. 操作系统:centos 6.7 x86_64, 操作系统基本环境提前准备过程略过。 

2. 二进制mysql版本:mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz 

3. 本安装过程也适合mysql-5.5.x二进制版本的安装过程参考。

二、安装mysql-5.6.29-linux-glibc2.5-x86_64

1. 下载编译版本mysql安装

wget http://mirrors.sohu.com/mysql/mysql-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz 

tar zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz  -c /usr/local

cd /usr/local/

ln -sv mysql-5.6.29-linux-glibc2.5-x86_64 mysql

2. 准备mysql用户

groupadd mysql

useradd -g mysql -m -s /sbin/nologin mysql

3. 初始化mysql,数据库位置采用默认位置

chown -r mysql:mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4. mysql服务配置

cd /usr/local/mysql

cp support-files/my-medium.cnf /etc/my.cnf 

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

chkconfig --add mysqld

chkconfig mysqld on

5. 配置mysql命令链接,也可以采用加入环境变量中,该方式可以略过。

ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql

ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump

ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk

ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe

或通过加入环境变量中解决。

# vi /etc/profile 

export path=/usr/local/mysql/bin/:$path

# source /etc/profile

6. 配置其它

ln -sv /usr/local/mysql/include  /usr/include/mysql 

echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf

ldconfig

7. mysql配置文件,仅是为了能启动测试

vi /etc/my.cnf

[client]

port        = 3306

default-character-set  = utf8

socket      = /tmp/mysql.sock

[mysqld]

character-set-server   = utf8 

collation-server       = utf8_general_ci 

port                   = 3306

socket                 = /tmp/mysql.sock

basedir                = /usr/local/mysql

datadir                = /usr/local/mysql/data

skip-external-locking

key_buffer_size    = 16m

max_allowed_packet = 1m

table_open_cache   = 64

sort_buffer_size   = 512k

net_buffer_length  = 8k

read_buffer_size   = 256k

read_rnd_buffer_size    = 512k

myisam_sort_buffer_size = 8m

log-bin=mysql-bin

binlog_format=mixed

server-id   = 1

[mysqldump]

quick

max_allowed_packet = 16m

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 20m

sort_buffer_size = 20m

read_buffer = 2m

write_buffer = 2m

[mysqlhotcopy]

interactive-timeout

8. 启动mysql

service mysqld start

9. 修改管理员密码并测试

# /usr/local/mysql/bin/mysqladmin -u root password 'admin' #设置管理员密码

# /usr/local/mysql/bin/mysql -u root -p   #测试密码输入

10. 配置mysql帐号安全

/usr/local/mysql/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] y

 ... success!

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] n

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...

 - removing privileges on test database...

reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

reload privilege tables now? [y/n] y

all done!  if you've completed all of the above steps, your mysql

installation should now be secure.

thanks for using mysql!

cleaning up...

继续阅读