首页  

mysql5.7二进制包安装说明     所属分类 mysql 浏览量 1421
https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

经典安装目录 /usr/local/mysql

MySQL has a dependency on the libaio library. 

yum install libaio 

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql

直接把解压出来的目录 放到 /usr/local , 改名为 /usr/local/mysql

shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql 
shell> bin/mysql_ssl_rsa_setup              
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

useradd -r -g mysql -s /bin/false mysql

-r 创建系统帐号,一般用来做系统服务

-s 指定用户登入后所使用的shell
-s /bin/false 不让 mysql 用户登录


chmod 750 mysql-files

7 属主(文件所有者)具有读,写和执行的权限,
5 文件所有者所在组的权限,有读和执行的权限 ,没有写入的权限
0 其他人没有权限

r 可读 w 可写 x 可执行
r=4 w=2 x=1

g group
o other

chmod g+r,o+r xxx.txt 

755   rwxr-xr-x



mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz  

[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# ls
bin  COPYING  docs  include  lib  man  README  share  support-files


[root@localhost mysql]# bin/mysqld --initialize --user=mysql 
2019-07-17T06:25:26.831812Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-17T06:25:26.982338Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-07-17T06:25:27.016518Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-07-17T06:25:27.070778Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: aab0b19e-a85b-11e9-8090-246e96270bd4.
2019-07-17T06:25:27.071219Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-07-17T06:25:27.071958Z 1 [Note] A temporary password is generated for root@localhost: xxxxxx


初始化 随机生成 root 密码

./bin/mysqld_safe --user=mysql &
[1] 20155
[root@localhost mysql]# Logging to '/usr/local/mysql/data/dyyx.err'.
2019-07-17T06:27:23.212401Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

[root@localhost mysql]# 


ps aux|grep mysql
root      20155  0.0  0.0 113264  1612 pts/0    S    14:27   0:00 /bin/sh ./bin/mysqld_safe --user=mysql
mysql     20225  0.3  0.2 1117132 178412 pts/0  Sl   14:27   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=dyyx.err --pid-file=dyyx.pid
root      20263  0.0  0.0 112676   984 pts/0    S+   14:28   0:00 grep --color=auto mysql

启动参数
 --basedir=/usr/local/mysql 
 --datadir=/usr/local/mysql/data 
 --plugin-dir=/usr/local/mysql/lib/plugin 
 --user=mysql 
 --log-error=dyyx.err 
 --pid-file=dyyx.pid

./mysql -u root -p

修改密码
set password="Tongdun@123";

data 目录 启动时创建

日志文件 默认在  data 目录下 
主机名.err

停止
./mysqladmin -u root -p shutdown



mysqld_safe 指定 配置文件

mysqld_safe --defaults-file=/etc/my2.cnf --user=mysql


安装成服务

cp support-files/mysql.server /etc/init.d/mysql.server
 /etc/rc.d/init.d  与   /etc/init.d 区别
 
 ll /etc/init.d
 /etc/init.d -> rc.d/init.d
 
 /etc/init.d 是 /etc/rc.d/init.d 的软链接
 
service mysql.server start
service mysql.server stop

没有 /etc/my.cnf  也可以启动

[mysqld]
# basedir = /data/mysql
# datadir = /data/mysql_data
port = 3306
server_id = 1
# socket = /data/mysql/3306/mysql.sock
# log-error = /data/mysql/logs/mysql.error
# pid-file = /data/mysql/3306/mysql.pid
character_set_server = utf8
collation-server = utf8_general_ci
lower_case_table_names = 1
max_allowed_packet = 100M
max_connections = 1000
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
[client]

[mysql]



参数查看 
show variables where Variable_name like 'character_set%';

show variables where Variable_name = 'max_connections';
 
修改 /etc/my.cnf 
max_connections 设置为 999

重启 MySQL ,查看参数是否生效

mysql> show variables where Variable_name = 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 999   |
+-----------------+-------+

上一篇     下一篇
kafka副本分布策略

kafka知识点

mysql5.7 /etc/my.cnf 配置

OceanBase知识点

私募股权投资简介

kafka高性能要点