搜索文章

FBLOG 简约不简单

数据库

数据库的知识都在这里。

mysql 5.7.9(GA) 安装

mysql 5.7.9(GA) 终于发布了,感受一下。

一、下载

下载页面 http://dev.mysql.com/downloads/mysql/

选择相应系统的版本下载。

本文OS为centos6.5 64bit 对应包为mysql-5.7.9-1.el6.x86_64.rpm-bundle

[root@TPCC2 ~]# ll mysql-5.7.9-1.el6.x86_64.rpm-bundle/

total 426792

-rw-r--r--. 1 root root 24134464 Oct 12 21:29 mysql-community-client-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 331912 Oct 12 21:30 mysql-community-common-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 3851928 Oct 12 21:30 mysql-community-devel-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 38081256 Oct 12 21:30 mysql-community-embedded-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 130479844 Oct 12 21:30 mysql-community-embedded-devel-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 2224356 Oct 12 21:31 mysql-community-libs-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 1720248 Oct 12 21:31 mysql-community-libs-compat-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 139636924 Oct 12 21:32 mysql-community-server-5.7.9-1.el6.x86_64.rpm

-rw-r--r--. 1 root root 96549460 Oct 12 21:33 mysql-community-test-5.7.9-1.el6.x86_64.rpm

二、 安装

按照rpm包依赖性,依次安装

[root@localhost mysql-5.7.9-1.el6.x86_64.rpm-bundle]# rpm -ivh mysql-community-common-5.7.9-1.el6.x86_64.rpm

warning: mysql-community-common-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ########################################### [100%]

1:mysql-community-common ########################################### [100%]

[root@localhost mysql-5.7.9-1.el6.x86_64.rpm-bundle]# rpm -ivh mysql-community-libs-*

warning: mysql-community-libs-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ########################################### [100%]

1:mysql-community-libs ########################################### [ 50%]

2:mysql-community-libs-co########################################### [100%]

[root@localhost mysql-5.7.9-1.el6.x86_64.rpm-bundle]# rpm -ivh mysql-community-client-5.7.9-1.el6.x86_64.rpm

warning: mysql-community-client-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ########################################### [100%]

1:mysql-community-client ########################################### [100%]

[root@localhost mysql-5.7.9-1.el6.x86_64.rpm-bundle]# rpm -ivh mysql-community-server-5.7.9-1.el6.x86_64.rpm

warning: mysql-community-server-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ########################################### [100%]

1:mysql-community-server ########################################### [100%]

[root@localhost mysql-5.7.9-1.el6.x86_64.rpm-bundle]# rpm -ivh mysql-community-devel-5.7.9-1.el6.x86_64.rpm

warning: mysql-community-devel-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ########################################### [100%]

1:mysql-community-devel ########################################### [100%]

三、初始化

1.创建用户和datadir目录

groupadd mysql

useradd -m -d /home/mysql -g mysql mysql

su - mysqlmkdir data

2.初始化my.cnf

[root@TPCC2 ~]# cat /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

[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

#

# 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

datadir=/home/mysql/data

socket=/home/mysql/data/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0

log-error=/home/mysql/data/mysqld.logpid-file=/home/mysql/data/mysqld.pid

3.初始化数据库

mysqld --initialize --user=mysql

默认使用/etc/my.cnf

[mysql@localhost data]$ pwd

/home/mysql/data

[mysql@localhost data]$ ll

total 110624

-rw-r-----. 1 mysql mysql 56 Oct 23 12:59 auto.cnf

-rw-r-----. 1 mysql mysql 407 Oct 23 12:59 ib_buffer_pool

-rw-r-----. 1 mysql mysql 12582912 Oct 23 12:59 ibdata1

-rw-r-----. 1 mysql mysql 50331648 Oct 23 12:59 ib_logfile0

-rw-r-----. 1 mysql mysql 50331648 Oct 23 12:59 ib_logfile1

drwxr-x---. 2 mysql mysql 4096 Oct 23 12:59 mysql

-rw-r-----. 1 mysql mysql 991 Oct 23 12:59 mysqld.log

drwxr-x---. 2 mysql mysql 4096 Oct 23 12:59 performance_schema

drwxr-x---. 2 mysql mysql 12288 Oct 23 12:59 sys

4.临时密码

查找初始用户、密码

[mysql@localhost data]$ grep "A temporary password" mysqld.log

2015-10-23T04:59:09.504285Z 1 [Note] A temporary password is generated for root@localhost: BdwK<Crzy08g

四、启动

[mysql@localhost ~]$ mysqld_safe --user=mysql &

[1] 11255

[mysql@localhost ~]$ 151023 13:01:37 mysqld_safe Logging to '/home/mysql/data/mysqld.log'.

151023 13:01:37 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data

[mysql@localhost data]$ tail -f mysqld.log

2015-10-23T05:01:38.114718Z 0 [Note] Plugin 'FEDERATED' is disabled.

2015-10-23T05:01:38.116051Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151023 13:01:38

2015-10-23T05:01:38.118122Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key

2015-10-23T05:01:38.118780Z 0 [Note] Server hostname (bind-address): '*'; port: 3306

2015-10-23T05:01:38.127582Z 0 [Note] IPv6 is available.

2015-10-23T05:01:38.127598Z 0 [Note] - '::' resolves to '::';

2015-10-23T05:01:38.127607Z 0 [Note] Server socket created on IP: '::'.

2015-10-23T05:01:38.143935Z 0 [Note] Event Scheduler: Loaded 0 events

2015-10-23T05:01:38.144134Z 0 [Note] /usr/sbin/mysqld: ready for connections.

Version: '5.7.9' socket: '/home/mysql/data/mysql.sock' port: 3306 MySQL Community Server (GPL)

五、登陆并修改临时密码

[mysql@TPCC2 ~]$ mysql -u root -h localhost -p -S /home/mysql/data/mysql.sock

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.9

Copyright (c) 2000, 2015, 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

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ? alter suer

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ? alter user

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> alter user 'root'@'localhost' identified by 'mysql';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)

mysql> exitBye

六、测试

1.新密码登陆

[mysql@localhost ~]$ mysql -u root -h localhost -S /home/mysql/data/mysql.sock -pmysql

mysql: [Warning] Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 5

Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

2.查看sys库

mysql> use sys

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+-----------------------------------------------+

| Tables_in_sys |

+-----------------------------------------------+

| host_summary |

| host_summary_by_file_io |

| host_summary_by_file_io_type |

| host_summary_by_stages |

| host_summary_by_statement_latency |

| host_summary_by_statement_type |

| innodb_buffer_stats_by_schema |

| innodb_buffer_stats_by_table |

| innodb_lock_waits |

| io_by_thread_by_latency |

| io_global_by_file_by_bytes |

| io_global_by_file_by_latency |

| io_global_by_wait_by_bytes |

| io_global_by_wait_by_latency |

| latest_file_io |

| memory_by_host_by_current_bytes |

| memory_by_thread_by_current_bytes |

| memory_by_user_by_current_bytes |

| memory_global_by_current_bytes |

| memory_global_total |

| metrics |

| processlist |

| ps_check_lost_instrumentation |

| schema_auto_increment_columns |

| schema_index_statistics |

| schema_object_overview |

| schema_redundant_indexes |

| schema_table_lock_waits |

| schema_table_statistics |

| schema_table_statistics_with_buffer |

| schema_tables_with_full_table_scans |

| schema_unused_indexes |

| session |

| session_ssl_status |

| statement_analysis |

| statements_with_errors_or_warnings |

| statements_with_full_table_scans |

| statements_with_runtimes_in_95th_percentile |

| statements_with_sorting |

| statements_with_temp_tables |

| sys_config |

| user_summary |

| user_summary_by_file_io |

| user_summary_by_file_io_type |

| user_summary_by_stages |

| user_summary_by_statement_latency |

| user_summary_by_statement_type |

| version |

| wait_classes_global_by_avg_latency |

| wait_classes_global_by_latency |

| waits_by_host_by_latency |

| waits_by_user_by_latency |

| waits_global_by_latency |

| x$host_summary |

| x$host_summary_by_file_io |

| x$host_summary_by_file_io_type |

| x$host_summary_by_stages |

| x$host_summary_by_statement_latency |

| x$host_summary_by_statement_type |

| x$innodb_buffer_stats_by_schema |

| x$innodb_buffer_stats_by_table |

| x$innodb_lock_waits |

| x$io_by_thread_by_latency |

| x$io_global_by_file_by_bytes |

| x$io_global_by_file_by_latency |

| x$io_global_by_wait_by_bytes |

| x$io_global_by_wait_by_latency |

| x$latest_file_io |

| x$memory_by_host_by_current_bytes |

| x$memory_by_thread_by_current_bytes |

| x$memory_by_user_by_current_bytes |

| x$memory_global_by_current_bytes |

| x$memory_global_total |

| x$processlist |

| x$ps_digest_95th_percentile_by_avg_us |

| x$ps_digest_avg_latency_distribution |

| x$ps_schema_table_statistics_io |

| x$schema_flattened_keys |

| x$schema_index_statistics |

| x$schema_table_lock_waits |

| x$schema_table_statistics |

| x$schema_table_statistics_with_buffer |

| x$schema_tables_with_full_table_scans |

| x$session |

| x$statement_analysis |

| x$statements_with_errors_or_warnings |

| x$statements_with_full_table_scans |

| x$statements_with_runtimes_in_95th_percentile |

| x$statements_with_sorting |

| x$statements_with_temp_tables |

| x$user_summary |

| x$user_summary_by_file_io |

| x$user_summary_by_file_io_type |

| x$user_summary_by_stages |

| x$user_summary_by_statement_latency |

| x$user_summary_by_statement_type |

| x$wait_classes_global_by_avg_latency |

| x$wait_classes_global_by_latency |

| x$waits_by_host_by_latency |

| x$waits_by_user_by_latency |

| x$waits_global_by_latency |

+-----------------------------------------------+

101 rows in set (0.00 sec)

原文  http://www.cnblogs.com/afx1007/p/4904238.html



搜索文章