2019-04-19

mysql

https://db-engines.com/en/ranking

远程授权问题:

https://blog.csdn.net/zhangfan_12871/article/details/77941386

oldguo

https://www.jianshu.com/p/dd7137c4efa5?tdsourcetag=s_pcqq_aiomsg

下面是安装步骤:

[root@localhost app]# mkdir /app/

[root@localhost app]# cd app/

[root@localhost app]# tar -xvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

2.解压并改名为mysql

[root@db01 app]# mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

[root@db01 app]# ls -l /app/mysql/

[root@localhost mysql]# vim /etc/profile

export PATH=/app/mysql/bin:$PATH

[root@localhost mysql]# useradd mysql

[root@localhost mysql]# mkdir /data/mysql -p

[root@localhost mysql]#  chown -R mysql.mysql /app/*

[root@localhost mysql]#  chown -R mysql.mysql /data/*

第一种初始化方法:安全机制较高

5.7开始,MySQL加入了全新的 密码的安全机制:

1.初始化完成后,会生成临时密码(显示到屏幕上,并且会往日志中记一份)

2.密码复杂度:长度:超过12位? 复杂度:字符混乱组合

3.密码过期时间180天

[root@localhost mysql]# mysqld --initialize --user=mysql --basedir=/app/mysql --datadir=/data/mysql

2019-04-18T11:21:29.019068Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-04-18T11:21:30.862403Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-04-18T11:21:31.041995Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-04-18T11:21:31.105659Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this serverhas been started. Generating a new UUID: 1db3ce3d-61cc-11e9-b9cf-000c293b5597.

2019-04-18T11:21:31.107276Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-04-18T11:21:31.109162Z 1 [Note] A temporary password is generated for root@localhost: kcre+CtLj0zh

第二种初始化方法:安全机制一般

初始化数据,初始化管理员的密码为空

[root@localhost data]# rm -rf mysql/*

[root@localhost data]# mysqld --initialize-insecure  --user=mysql --basedir=/app/mysql --datadir=/data/mysql

2019-04-18T11:38:04.560602Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-04-18T11:38:06.740715Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-04-18T11:38:06.976313Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-04-18T11:38:07.040330Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this serverhas been started. Generating a new UUID: 6f53608b-61ce-11e9-91c8-000c293b5597.

2019-04-18T11:38:07.041920Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-04-18T11:38:07.043794Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

初始化完了之后在/data/mysql目录下能看到这些文件

[root@localhost mysql]# pwd

/data/mysql

[root@localhost mysql]# ll

total 110628

-rw-r-----. 1 mysql mysql      56 Apr 18 19:38 auto.cnf

-rw-r-----. 1 mysql mysql      419 Apr 18 19:38 ib_buffer_pool

-rw-r-----. 1 mysql mysql 12582912 Apr 18 19:38 ibdata1

-rw-r-----. 1 mysql mysql 50331648 Apr 18 19:38 ib_logfile0

-rw-r-----. 1 mysql mysql 50331648 Apr 18 19:38 ib_logfile1

drwxr-x---. 2 mysql mysql    4096 Apr 18 19:38 mysql

drwxr-x---. 2 mysql mysql    8192 Apr 18 19:38 performance_schema

drwxr-x---. 2 mysql mysql    8192 Apr 18 19:38 sys

添加配置文件:

[root@localhost mysql]# cat /etc/my.cnf

[mysqld]

user=mysql

basedir=/app/mysql

datadir=/data/mysql

server_id=6

port=3306

socket=/tmp/mysql.sock

[mysql]

socket=/tmp/mysql.sock

prompt=3306 [\\d]>

[root@localhost mysql]# cp /app/mysql/support-files/mysql.server  /etc/init.d/mysqld

[root@localhost mysql]# service mysqld stop

Shutting down MySQL.. SUCCESS!

设置下面的内容便可以使用systemctl使用mysql了

vim /etc/systemd/system/mysqld.service 

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=

http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/app/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000

[root@localhost mysql]# mysqladmin -uroot -p password 123

你可能感兴趣的:(2019-04-19)