- 创建mysql组和用户
groupadd mysql
useradd -r -g mysql mysql
- 下载MYSQL5.7.19二进制包,上传至服务器的usr/local目录下
cd /usr/local
ll
- 解压MYSQL5.7.19二进制包
tar -zxvf /Ultrapower/test/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
- 重命名文件夹信息
mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
- 更改所属的组和用户
chown -R mysql mysql/
chgrp -R mysql mysql/
- 解压之后的MYSQL文件包含的内容
cd mysql/
ll
创建my_default.cnf配置文件
code:my_default.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# 一般配置选项
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
[client]
/bin/bash: Q: command not found
- 将my_default.cnf上传至support-files文件夹中
cp my_default.cnf /usr/local/mysql/support-files
- 创建data文件夹
cd usr/local/mysql
mkdir data
- 注册和初始化MYSQL服务
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
- 复制上述的my_default.cnf和mysql.server配置文件到etc目录,它这里提示是否覆盖,输入Y覆盖
cp -a /usr/local/mysql/support-files/my_default.cnf /etc/my.cnf
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- 启动MYSQL服务
cd bin/
./mysql_safe --user=mysql
/etc/init.d/mysqld restart
- 连接至MYSQL,默认没有密码,直接回车后连接至MYSQL
./mysql -u root -p
- 修改MYSQL的root密码
set password = password('123456');
- 修改可远程访问
update user set host = '%' where user = 'root';
- 重启MYSQL服务
/etc/init.d/mysqld restart