在centos6.7上安装mysql5.7.18

xiaoxiao2025-07-15  6

首先下载mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

然后解压 tar -xvzf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

要想好 datadir 和basedir两个路径。

我把这个压缩包,解压后,重名为为mysql,放在 /opt/mysql

然后/opt/mysql/下面有个bin文件

 

bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

执行完了,会出现一个临时密码,一定要记住这个临时密码:

[hadoop@Master mysql]$ sudo bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

2018-10-25T06:48:28.899955Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-10-25T06:48:29.467625Z 0 [Warning] InnoDB: New log files created, LSN=45790

2018-10-25T06:48:29.645286Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-10-25T06:48:29.786048Z 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: fb628d21-d821-11e8-8cdc-005056b20471.

2018-10-25T06:48:29.804129Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2018-10-25T06:48:29.804705Z 1 [Note] A temporary password is generated for root@localhost: >xHYOl:s<6V7

 

 

如果要装ssl,那么紧接着要执行下面这一步:

bin/mysql_ssl_rsa_setup      --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

 

 

将mysql进程放入系统进程中,命令如下:

先修改这个support-files/mysql.server,把里面的basedir和datadir都改一下。

然后

cp support-files/mysql.server /etc/init.d/mysqld

如果my.cnf 不存在,可以直接复制别人的my.cnf过来。改下对应参数。

 

启动 sudo /etc/init.d/mysqld restart

第一次root账号进去,会要求你改密码:

alter user 'root'@'localhost' identified by 'zhelishinizijishezhidexinmima';

 

 

参考:

生成pem :https://www.cnblogs.com/mysql-dba/p/7061300.html 安装mysql:http://www.bubuko.com/infodetail-2164257.html

 

注意,如果感觉装得不对,可以重来的,很简单,就是把datadir下面的都清除(都删掉),

然后重新执行

bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

 

 

要注意basefile 和 datafile的所有者必须是mysql,经常要执行

chown -R mysql:mysql  /opt/files/mysql

chown -R mysql:mysql  /opt/files/mysql_data_file

 

还有,

use user;

select * from user where user='root';

update user set password_expired ="NO" where user='root';

 

 

 

 

转载请注明原文地址: https://www.6miu.com/read-5033107.html

最新回复(0)