MySQL5.7二进制简单安装

系统:centos7.2
mysql安装包:mysql-5.7.18-linux-glibc2.12-x86_64.tar.gz

tar -zxvf mysql-5.7.18-linux-glibc2.12-x86_64.tar.gz

MySQL5.7二进制简单安装_第1张图片
bin目录下主要的工具
mysql:客户端
mysqladmin
mysqlbinlog
mysqld:mysql二进制文件
mysql_safe:启停mysql
mysqldump:导出工具

**

1.先指定安装目录,创建配置文件和用户

**

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
mkdir mysql-files
chown mysql:mysql /mysql_data
chmod 750 /mysql_data

vim /etc/my3306.cnf
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
port=3306
socket=/tmp/mysql3306.sock
user=mysql
datadir=/mysql_data

**

2.初始化数据库

**


bin/mysqld --initialize --user=mysql --datadir=/mysql_data

输出结果为:
2018-08-29T06:40:53.371994Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see docume
ntation for more details).2018-08-29T06:40:53.372269Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' co
nfiguration directive.2018-08-29T06:40:54.667114Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-29T06:40:54.836217Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-29T06:40:54.905062Z 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 n
ew UUID: 7ab5788b-ab56-11e8-a9a3-000c29ce964b.2018-08-29T06:40:54.906385Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-29T06:40:54.907698Z 1 [Note] A temporary password is generated for root@localhost: gYRZitVcU3:/

*****没有指定timestamp,不用管
*****找不到错误信息的error,
*****创建
*****初始化uuid
*****没有开gtid
****************随机密码,只能用于第一次改密码使用gYRZitVcU3:/

初始化后生成如下文件
MySQL5.7二进制简单安装_第2张图片

以下是三个默认数据库
mysql:授权相关的东西
performance_schema:性能相关
sys:mysql5.7吸收的第三方的东西
**

3.启动mysql

**

bin/mysqld_safe --defaults-file=/etc/my3306.cnf &

注意加上&后台运行
在这里插入图片描述
正常启动会输出两个东西,输出错误日志和mysqld_safe正在启动
错误日志名称默认机器主机名

启动成功的标志是2018-08-29T07:03:36.216571Z 0 [Note] /root/mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqld: ready for connections.

**

4.登录并修改密码

**

bin/mysql -S /tmp/mysql3306.sock -uroot -p
#输入初始化的时候的随机密码

alter user 'root'@'localhost' identified by 'P@ssw0rd';
flush privileges;
quit;
#重新用新密码登录
bin/mysql -S /tmp/mysql3306.sock -uroot -p

你可能感兴趣的:(MySQL)