博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL-5.6.x二进制版本安装记录
阅读量:6356 次
发布时间:2019-06-23

本文共 4203 字,大约阅读时间需要 14 分钟。

一、操作系统安装环境

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

 ... skipping.

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

本文转自 koumm 51CTO博客,原文链接:http://blog.51cto.com/koumm/1762167,如需转载请自行联系原作者
你可能感兴趣的文章
2009年程序员考试大纲指南
查看>>
SQL安全管理范例-创建一个只能在应用程序中登录才有权限的用户.sql
查看>>
[zz] convirt 安装指南
查看>>
HUT-1697 棋盘覆盖
查看>>
ubuntu 12.04 lamp配置
查看>>
atitit。浏览器缓存机制 and 微信浏览器防止缓存的设计 attilax 总结
查看>>
用JAX-WS在Tomcat中公布WebService
查看>>
meclipse中project facet问题
查看>>
.NET Core的日志[3]:将日志写入Debug窗口
查看>>
Linux异步IO【转】
查看>>
第1阶段——u-boot分析之make 100ask24x0_config指令(1)
查看>>
Activiti源码学习:ExecutionListener与TaskListener的区别
查看>>
多线程 ForkJoinPool
查看>>
SPI最大传输速率【转】
查看>>
记录阿里云服务器mysql被黑
查看>>
GPS轨迹数据集免费下载资源整理
查看>>
JavaScript中的Generator函数
查看>>
CentOS6.5安装ElasticSearch6.2.3
查看>>
新手站长:成功申请Godaddy域名退款到支付宝全过程
查看>>
cisco 查看接口进出流量
查看>>