mysql-5.7安装

1、下载依赖和数据库安装包

yum -y install libaio  libaio-devel
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz  

2、配置环境

tar xvf MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 
mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql

创建启动用户

useradd -s /sbin/nologin -M mysql

创建数据存放路径

mkdir mkdir mysql-5.7.17/data -p
mkdir mysql-5.7.17/log
chown -R mysql:mysql mysql-5.7.17

编辑my.cnf

[root@localhost mysql]# cat /etc/my.cnf 
[client]
port = 3308
socket = /tmp/mysql.sock

[mysqld]
server_id=10
port = 3308
user = mysql
character-set-server = utf8mb4
default_storage_engine = innodb
log_timestamps = SYSTEM
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql-5.7.17/data
pid-file = /data/mysql-5.7.17/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 = /data/mysql-5.7.17/log/mysql-error.log 
slow_query_log = 1
long_query_time = 1 
slow_query_log_file = /data/mysql-5.7.17/log/mysql-slow.log

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

初始化:

bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql

初始密码可以查看:cat /data/mysql-5.7.17/log/mysql-error.log

拷贝启动脚本

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

更改mysqld启动参数

vim /etc/init.d/mysqld 
basedir=/usr/local/mysql
datadir=/data/mysql-5.7.17/data

授权

chmod 755 /etc/init.d/mysqld

3、启动、连接(5.7版本的数据库,密码会随机生成,保存在error.log里面)

/etc/init.d/mysql start
cd /usr/local/mysql
./bin/mysql -uroot -ph*pkEiZTy84/

进去之后先改密码,然后做不了其他操作:

ALTER USER 'root'@'localhost' IDENTIFIED BY  '123456';

猜你喜欢

转载自blog.csdn.net/qq_25611295/article/details/79011511