mysql5.7通用二进制安装的临时密码在哪?

软件和网站开发以及相关技术探讨
回复
kidkey
帖子: 28
注册时间: 2017-09-21 14:46
系统: ubuntu16.04

mysql5.7通用二进制安装的临时密码在哪?

#1

帖子 kidkey » 2018-05-12 16:05

之前一直用5.5,想二进制安装5,7
发现变化挺大的就是初始化了

/application/mysql/bin/mysqld --initialize --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

当开启服务,发现需要密码 ,查到--initializ 参数会生成随机密码在错误日志中,查了半天怎么没有??恼火

代码: 全选

[root@VM_159_120_centos mysql]# cat /etc/my.cnf 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@VM_159_120_centos mysql]# 

代码: 全选

[root@VM_159_120_centos mysql]# cat /var/log/mysqld.log
2018-05-12T07:22:55.107308Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-12T07:22:55.107409Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-05-12T07:22:55.107442Z 0 [Note] /application/mysql/bin/mysqld (mysqld 5.7.21) starting as process 12129 ...
2018-05-12T07:22:55.120834Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-05-12T07:22:55.120862Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-12T07:22:55.120866Z 0 [Note] InnoDB: Uses event mutexes
2018-05-12T07:22:55.120869Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2018-05-12T07:22:55.120872Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-12T07:22:55.120875Z 0 [Note] InnoDB: Using Linux native AIO
2018-05-12T07:22:55.121105Z 0 [Note] InnoDB: Number of pools: 1
2018-05-12T07:22:55.121198Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-12T07:22:55.122452Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-12T07:22:55.130166Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-12T07:22:55.132205Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-05-12T07:22:55.149462Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-12T07:22:55.168416Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-12T07:22:55.168462Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-12T07:22:55.226198Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-12T07:22:55.227073Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-12T07:22:55.227084Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-12T07:22:55.227305Z 0 [Note] InnoDB: Waiting for purge to start
2018-05-12T07:22:55.277513Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 2551166
2018-05-12T07:22:55.278480Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-05-12T07:22:55.279158Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-12T07:22:55.293376Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180512 15:22:55
2018-05-12T07:22:55.295522Z 0 [Warning] Failed to set up SSL because of the following SSL librar
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: mysql5.7通用二进制安装的临时密码在哪?

#2

帖子 astolia » 2018-05-12 16:22

你对一个[mysqld] 一个 [mysqld_safe]就没点想法? https://dev.mysql.com/doc/refman/5.7/en ... -safe.html
kidkey
帖子: 28
注册时间: 2017-09-21 14:46
系统: ubuntu16.04

Re: mysql5.7通用二进制安装的临时密码在哪?

#3

帖子 kidkey » 2018-05-12 17:04

astolia 写了:你对一个[mysqld] 一个 [mysqld_safe]就没点想法? https://dev.mysql.com/doc/refman/5.7/en ... -safe.html
英语太渣主要是

另外也看文档了 很郁闷

我的理解是 5.7之后弃用mysql_install_db脚本 功能集成在mysqld脚本里了

我对这个mysqld脚本二进制安装不熟悉. 以前的操作都是安装时不指定密码,登陆再改.
第一次安装不熟悉 使用了--initialize,后来才知道--initialize-insecure才是不生成密码

文档上说--initialize 会生成随机密码在errorlog里面,网上也这么说,找半天就是找不到啊 root家目录下也没有隐藏的mysql文件

mysqld_safe我一直把它理解成和mysql.server一样的启动脚本,我不喜欢后台启动 一直不用它,都是把mysql.server放到init.d 启动的 没有深入研究mysqld_safe

还有怎么没有默认的mysql.conf模板了 类似于my-small.cnf 需要自己写吗

我是很渣 但是很郁闷 mysql文档高大上,可是变化深深的藏在制式文档某处.让人很无语.对新手不友善.比如哪个版本不在提供配置模板 没有说.

我的环境centos6.9 mysql-5.7.21

tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
useradd mysql -s /sbin/nologin -M
mv mysql-5.7.21-linux-glibc2.12-x86_64 /application/
ln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql
/application/mysql/bin/mysqld --initialize --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

问题在哪?难道是我没有指定路径权限 就找不到它随机的密码吗 我一般都是配置之后一起chown -R mysql.mysql的

我现在很郁闷的爬坑 我再试试去

另外下面这是官网文档5.7版本二进制推荐安装

代码: 全选

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
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
kidkey
帖子: 28
注册时间: 2017-09-21 14:46
系统: ubuntu16.04

Re: mysql5.7通用二进制安装的临时密码在哪?

#4

帖子 kidkey » 2018-05-12 17:16

郁闷
随机密码居然在初始化之后的输出

代码: 全选

[root@VM_159_120_centos mysql]# /application/mysql/bin/mysqld --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/ --initialize
2018-05-12T09:10:48.098740Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-12T09:10:48.576592Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-12T09:10:48.636947Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-12T09:10:48.694564Z 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: 5c6616b2-55c4-11e8-8914-5254004d7a4f.
2018-05-12T09:10:48.695793Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-12T09:10:48.698117Z 1 [Note] A temporary password is generated for root@localhost: [b]S;&>,i:69Z?C[/b]
此时log-error=/var/log/mysqld.log根本就没生成 自然随机密码写不到,等生成之后 当然看不到随机密码
[root@VM_159_120_centos mysql]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

代码: 全选

[root@VM_159_120_centos mysql]# cat /var/log/mysqld.log
cat: /var/log/mysqld.log: No such file or directory
[root@VM_159_120_centos mysql]# cat /var/log/mysqld.log 
cat: /var/log/mysqld.log: No such file or directory
[root@VM_159_120_centos mysql]# 
试了N遍 非常郁闷 官网还告诉去错误日志找
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: mysql5.7通用二进制安装的临时密码在哪?

#5

帖子 astolia » 2018-05-12 17:22

官网没有说错啊,密码就是在错误日志中。
当配置文件中没有指定log-error项时,错误日志是直接输出到控制台的。 https://dev.mysql.com/doc/refman/5.7/en ... -unix.html
[mysqld]下面并没有指定log-error,当然就是你看到的这么一回事了。
[mysqld_safe]下面的log-error只在你用mysqld_safe启动时才会去用到。这些在文档中都写明白了的

英文不好的话更要加强这方面的阅读训练。其实这类的文档语法不会超过高中英语,初中英语也能凑合,就是多一些专业词汇,多看也就熟了。
kidkey
帖子: 28
注册时间: 2017-09-21 14:46
系统: ubuntu16.04

Re: mysql5.7通用二进制安装的临时密码在哪?

#6

帖子 kidkey » 2018-05-12 17:43

astolia 写了:官网没有说错啊,密码就是在错误日志中。
当配置文件中没有指定log-error项时,错误日志是直接输出到控制台的。 https://dev.mysql.com/doc/refman/5.7/en ... -unix.html
[mysqld]下面并没有指定log-error,当然就是你看到的这么一回事了。
[mysqld_safe]下面的log-error只在你用mysqld_safe启动时才会去用到。这些在文档中都写明白了的

英文不好的话更要加强这方面的阅读训练。其实这类的文档语法不会超过高中英语,初中英语也能凑合,就是多一些专业词汇,多看也就熟了。
了解了 还是不扎实 还真得多训练看官网文档

对了 什么 版本开始没有配置文件模板的 难道需要自己备份吗
还有你们是怎么配置的.我一直想知道 .我以前都是改配置文档,从不自己手写,感觉很累的
高手难道都是直接写配置文件 mysql不提供配置文件 就是这个意思吗?
我不喜欢想rsync那样需要自己新建 或者手写配置选项 而是喜欢想nginx那种 改就可以

难道提高水平 需要默写配置选项吗

还有发现不是英语多差,,,,是选择性看不见 可能是天生的逃避心里
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: mysql5.7通用二进制安装的临时密码在哪?

#7

帖子 astolia » 2018-05-14 12:05

我不用mysql,所以也不知道它的模板配置文件是怎么回事。
一般而言,数据库的配置文件是从简单到复杂随使用慢慢调整逐步积累起来的,需求不变的话,配置文件也不会去改动。
网上的模板一搜一大把,觉得需求差不多就直接拿来改改用就是了,没必要在这上面纠结。况且不管是从0开始新建还是修改模板,基本都是一次性的投入,弄好后可以管很久,花费的那一点时间和整个使用周期相比根本不算什么。
默写之类的纯粹就是搞笑了。一般都是先明确需要什么功能,然后提取出关键字上用英文google搜相关的配置选项。我现在管理的数据库我也最多只记得配置了哪些功能,你要问我具体是哪些配置,我不看配置文件或文档我也答不出来

想逃避一般是看到一大篇英文吓懵了。这类技术文档是为了把事情说清楚,都有固定的结构,不会跟你绕来绕去把中心思想藏得很深。看多了也就知道需要找的信息会出现在什么位置,再在网页内搜索一下关键字,可以轻松过滤掉不需要的信息找到重点
回复