mysql二进制安装

Posted 会飞的板儿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql二进制安装相关的知识,希望对你有一定的参考价值。

上传文件并解压

[[email protected] ~]# cd /usr/local/
[[email protected] local]# ls mysql*
mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
[[email protected] local]# tar zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz


解压完毕之后创建软连接

[[email protected] local]# ln -s mysql-5.7.9-linux-glibc2.5-x86_64 mysql

[[email protected] local]# cd mysql
[[email protected] mysql]# ll
total 160
drwxr-xr-x 2 7161 wheel 4096 Oct 12 2015 bin
-rw-r--r--    1 7161 wheel 17987 Oct 12 2015 COPYING
drwxr-xr-x  2 7161 wheel 4096 Oct 12 2015 docs
drwxr-xr-x  3 7161 wheel 4096 Oct 12 2015 include
-rw-r--r--     1 7161 wheel 108028 Oct 12 2015 INSTALL-BINARY
drwxr-xr-x   5 7161 wheel 4096 Oct 12 2015 lib
drwxr-xr-x   4 7161 wheel 4096 Oct 12 2015 man
-rw-r--r--     1 7161 wheel 2478 Oct 12 2015 README
drwxr-xr-x 28 7161 wheel 4096 Oct 12 2015 share
drwxr-xr-x   2 7161 wheel 4096 Oct 12 2015 support-files


创建用户及组

[[email protected] mysql]# groupadd mysql
[[email protected] mysql]# useradd -r -g mysql mysql

 

为mysql路径下面的文件进行用户和组的修改

[[email protected] mysql]# chown -R mysql .
[[email protected] mysql]# chgrp -R mysql .

 

创建数据文件和日志文件路径

[[email protected] local]# mkdir /mydata /mydata/data /mydata/log
[[email protected] mysql]# chown -R mysql:mysql /mydata

 

创建my.cnf文件

[[email protected] mysql]# vi /etc/my.cnf

[client]
port = 3306
socket = /var/lib/mysql/mysql.sock

[mysqld]
server_id=10
port = 3306
user = mysql
character-set-server = utf8mb4
default_storage_engine = innodb
log_timestamps = SYSTEM
socket = /var/lib/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /mydata/data
pid-file = /mydata/data/mysql.pid
max_connections = 1000
max_connect_errors = 1000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
#####====================================[innodb]==============================
innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path=ibdata1:1024M:autoextend

#####====================================[log]==============================
log_error = /mydata/log/mysql-error.log 
slow_query_log = 1
long_query_time = 1 
slow_query_log_file = /mydata/log/mysql-slow.log

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

初始化数据库

在5.7.6之前初始化的方法是:bin/mysql_install_db --user=mysql

5.7.6之后的版本初始化数据库不再使用mysql_install_db

[[email protected] mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp
[[email protected] mysql]# bin/mysql_ssl_rsa_setup --datadir=/mydata/data

 

如果配置了my.cnf的log_error,那么初始密码在log_error文件中,否则会打印出来。


初始完毕之后更改/usr/local/mysql路径下面文件的所属用户

[[email protected] mysql]# chown -R root .

 

配置启动文件

cp support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
service mysql start

 

配置环境变量

[[email protected] ~]# vi /etc/profile
mysql_home=/usr/local/mysql
PATH=$PATH:$mysql_home/bin
source /etc/profile


修改密码

在5.7中存储密码的字段不再是password了,变成了authentication_string

update mysql.user set authentication_string=password(‘root‘) where user=‘root‘;
修改root密码后如果第一次使用root用户登入mysql系统还会需要重置一次root密码

SET PASSWORD=PASSWORD(‘root‘);
flush privileges;

 







以上是关于mysql二进制安装的主要内容,如果未能解决你的问题,请参考以下文章

Redhat Linux上mysql安装-binary package安装

Linux平台下安装MySQL

Mysql的二进制安装和基础入门操作

源码安装部署MySQL数据库 二进制安装部署MySQL数据库 yum安装数据库

怎样区分linux下的二进制和源代码Mysql包?

mysql基础进阶