1、上传包 mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar到/home目录下
2、创建目录:mkdir -p /home/mysql-5.7.29
3、解压包
cd /home
gzip mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
tar zxvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar.gz -C /home/mysql-5.7.29/
4、安装mysql
yum localinstall /home/mysql-5.7.29/*
5、改mysql配置文件 vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
default-time-zone = '+8:00'
symbolic-links=0
port=3306
bind-address=0.0.0.0
log_bin = mysql-bin
server-id = 100
expire_logs_days = 10
max_binlog_size = 100M
sync_binlog = 1
binlog_checksum = none
binlog_format = mixed
binlog_cache_size = 32M
max_connections = 1000
slow_query_log=on
long_query_time=1
skip-host-cache
skip-name-resolve
lower_case_table_names=1
character-set-server=utf8
max_allowed_packet=100M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
skip-grant-tables #无密码登录
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
6、启动mysql
service mysqld start
7、查看mysql状态
service mysqld status
8、连接mysql
mysql -uroot -p 回车无密码登录
9、设置密码
mysql> flush privileges;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jzm@test123';
10、注释/etc/my.cnf中的skip-grant-tables,密码登录
#skip-grant-tables
11、重启mysql
service mysqld restart
12、创建用户
create user 'aks'@'%' identified by '5b@7cugUROXe4T8S';
13、赋权限
grant all privileges on . to 'aks'@'%' identified by '5b@7cugUROXe4T8S';
14、刷新缓存(生效)
flush privileges;
15、连接aks用户
mysql -uaks -p5b@7cugUROXe4T8S
16、创建databses
CREATE DATABASE IF NOT EXISTS aks DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
17、创建tables
use aks;
source $pwd/scripts/authsysdb_ddl.sql;
source $pwd/scripts/keysysdb_ddl.sql;
临时改mysql最大连接数:
show variables like 'max_connections';
set global max_connections = 10000;
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> set global max_connections = 10000;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 10000 |
+-----------------+-------+
1 row in set (0.00 sec)
create user 'aks'@'localhost' identified by 'Jdjrsecdev@jzmtest';
set password for aks@localhost = password('Jdjrsecdev@jzmtest');
flush privileges;
update mysql.user set host='%' where user='aks';
flush privileges;
GRANT ALL PRIVILEGES ON . TO 'aks'@'%' IDENTIFIED BY 'Jdjrsecdev@jzmtest';
flush privileges;
update mysql.user set password=password('Jdjrsecdev@jzmtest') where user='aks' and host='%';
update mysql.user set authentication_string=password('Jdjrsecdev@jzmtest') where user='aks' and host='%';
FLUSH PRIVILEGES;
grant all privileges on aksnew.* to aks@'%';
grant all privileges on casysnew.* to aks@'%';
FLUSH PRIVILEGES;