ITeye博客

centos8上安装mysql5.7.16

hangzhoujava · 2017-04-21 09:45 · mysql · 数据库 · Markdown

[root@iZwz94knyxhkgqeu5pve0zZ bin]# cd /usr/local/mysql

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysqld --initialize --user=mysql --basedir=/u

sr/local/mysql

2017-04-21T01:09:02.837622Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-04-21T01:09:05.621663Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-04-21T01:09:06.007022Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-04-21T01:09:06.103758Z 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: 1da93999-262f-11e7-a713-00163e06a307.

2017-04-21T01:09:06.109542Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2017-04-21T01:09:06.110557Z 1 [Note] A temporary password is generated for root@localhost: MX,)LrHRq6gn

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysql_ssl_rsa_setup

Generating a 2048 bit RSA private key

.........+++

................................................................................................................................................+++

writing new private key to 'ca-key.pem'

-----

Generating a 2048 bit RSA private key

...............+++

..........................................+++

writing new private key to 'server-key.pem'

-----

Generating a 2048 bit RSA private key

........+++

........................................+++

writing new private key to 'client-key.pem'

-----

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# cd /usr/local/mysql/support-files

[root@iZwz94knyxhkgqeu5pve0zZ support-files]# cp my-default.cnf /etc/my.cnf

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

[root@iZwz94knyxhkgqeu5pve0zZ support-files]# vim /etc/my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

 

[mysqld]

 

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

 

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

 

# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# socket = .....

 

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

~

~

~

~

~

~

~

"/etc/my.cnf" 31L, 1126C 1,1 All

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

 

[mysqld]

 

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

 

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

 

# These are commonly set, remove the # and set as required.

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

# server_id = .....

socket = /tmp/mysql.sock

 

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

~

~

~

~

~

~

~

"/etc/my.cnf" 31L, 1154C written

[root@iZwz94knyxhkgqeu5pve0zZ support-files]# cd ../

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysqld-safe --user=mysql &

[1] 21491

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# cd data

[root@iZwz94knyxhkgqeu5pve0zZ data]# chmod a+rw server-key.pem

[root@iZwz94knyxhkgqeu5pve0zZ data]# cd ../

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysqld_safe --user=mysql &

[2] 21686

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysql --user=root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@iZwz94knyxhkgqeu5pve0zZ mysql]# bin/mysql --user=root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.16

 

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> set password=password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> grant all privileges on *.* to root@'%' identified by '123456';

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

另外启动一个窗口,/etc/profile文件修改添加一句话export PATH=/usr/local/mysql/bin:$PATH

vim /etc/profile的过程省略

[root@iZwz94knyxhkgqeu5pve0zZ ~]# source /etc/profile

[root@iZwz94knyxhkgqeu5pve0zZ ~]# chmod 755 /etc/init.d/mysql

[root@iZwz94knyxhkgqeu5pve0zZ ~]# chkconfig --add mysql

[root@iZwz94knyxhkgqeu5pve0zZ ~]# chkconfig --level 345 mysql on

 

 注意绿色的字体是生成的mysql初始化密码啊

结束

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。