linux下mysql的安装
一、环境
1、centos6.5-64位
mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
二、安装(上传、解压、指定用户、创建mysql目录、权限)
创建目录mkdir -p/opt/mysql
进入目录cd /opt/mysql
解压mysql安装包tar zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
server_id=10
port = 3306
user = mysql
character-set-server = utf8
default_storage_engine = innodb
log_timestamps = SYSTEM
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/mysql/data
pid-file=/mysql/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_force_recovery=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 = /mysql/log/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /mysql/log/mysql-slow.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
~
修改目录权限
chown -R mysql:mysql /usr/local/mysql /mysql
配置启动文件
cp support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
service mysql start
配置环境变量
mysql_home=/usr/local/mysql
PATH=$PATH:$mysql_home/bin
source /etc/profile
启动数据库
service mysql start、
停止数据库
mysql stop
重新启动数据库
service mysqlrestart
进入数据库
mysql -uroot