二、安裝數(shù)據(jù)庫(kù)軟件 MySQL-server-5.6.28-1.el6.x86_64.rpm MySQL-client-5.6.28-1.el6.x86_64.rpm MySQL-devel-5.6.28-1.el6.x86_64.rpm # rpm -ivh MySQL-server-5.6.28-1.el6.x86_64.rpm warning: MySQL-server-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MySQL-server ########################################### [100%] 2016-01-18 14:42:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-01-18 14:42:21 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1671 ... 2016-01-18 14:42:21 1671 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-01-18 14:42:21 1671 [Note] InnoDB: The InnoDB memory heap is disabled 2016-01-18 14:42:21 1671 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-01-18 14:42:21 1671 [Note] InnoDB: Memory barrier is not used 2016-01-18 14:42:21 1671 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-01-18 14:42:21 1671 [Note] InnoDB: Using Linux native AIO 2016-01-18 14:42:21 1671 [Note] InnoDB: Using CPU crc32 instructions 2016-01-18 14:42:21 1671 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-01-18 14:42:21 1671 [Note] InnoDB: Completed initialization of buffer pool 2016-01-18 14:42:21 1671 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2016-01-18 14:42:21 1671 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 2016-01-18 14:42:21 1671 [Note] InnoDB: Database physically writes the file full: wait... 2016-01-18 14:42:21 1671 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2016-01-18 14:42:22 1671 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2016-01-18 14:42:22 1671 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2016-01-18 14:42:22 1671 [Warning] InnoDB: New log files created, LSN=45781 2016-01-18 14:42:22 1671 [Note] InnoDB: Doublewrite buffer not found: creating new 2016-01-18 14:42:22 1671 [Note] InnoDB: Doublewrite buffer created 2016-01-18 14:42:22 1671 [Note] InnoDB: 128 rollback segment(s) are active. 2016-01-18 14:42:22 1671 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-01-18 14:42:22 1671 [Note] InnoDB: Foreign key constraint system tables created 2016-01-18 14:42:22 1671 [Note] InnoDB: Creating tablespace and datafile system tables. 2016-01-18 14:42:22 1671 [Note] InnoDB: Tablespace and datafile system tables created. 2016-01-18 14:42:22 1671 [Note] InnoDB: Waiting for purge to start 2016-01-18 14:42:22 1671 [Note] InnoDB: 5.6.28 started; log sequence number 0 A random root password has been set. You will find it in '/root/.mysql_secret'. 2016-01-18 14:42:22 1671 [Note] Binlog end 2016-01-18 14:42:22 1671 [Note] InnoDB: FTS optimize thread exiting. 2016-01-18 14:42:22 1671 [Note] InnoDB: Starting shutdown... 2016-01-18 14:42:24 1671 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2016-01-18 14:42:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-01-18 14:42:24 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1693 ... 2016-01-18 14:42:24 1693 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-01-18 14:42:24 1693 [Note] InnoDB: The InnoDB memory heap is disabled 2016-01-18 14:42:24 1693 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-01-18 14:42:24 1693 [Note] InnoDB: Memory barrier is not used 2016-01-18 14:42:24 1693 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-01-18 14:42:24 1693 [Note] InnoDB: Using Linux native AIO 2016-01-18 14:42:24 1693 [Note] InnoDB: Using CPU crc32 instructions 2016-01-18 14:42:24 1693 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-01-18 14:42:24 1693 [Note] InnoDB: Completed initialization of buffer pool 2016-01-18 14:42:24 1693 [Note] InnoDB: Highest supported file format is Barracuda. 2016-01-18 14:42:24 1693 [Note] InnoDB: 128 rollback segment(s) are active. 2016-01-18 14:42:24 1693 [Note] InnoDB: Waiting for purge to start 2016-01-18 14:42:24 1693 [Note] InnoDB: 5.6.28 started; log sequence number 1625977 2016-01-18 14:42:24 1693 [Note] Binlog end 2016-01-18 14:42:24 1693 [Note] InnoDB: FTS optimize thread exiting. 2016-01-18 14:42:24 1693 [Note] InnoDB: Starting shutdown... 2016-01-18 14:42:26 1693 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database. This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings
把mysql開(kāi)機(jī)自啟關(guān)閉 #chkconfig --level 2345 mysql off # chkconfig --list mysql mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
三、配置MySQL數(shù)據(jù)庫(kù)參數(shù)文件my.cnf 編輯 my.cnf文件 #vi /usr/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/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 = 512M
# 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 datadir = /mysql/data/mysqldata/mydata port = 3306 socket = /mysql/data/mysqldata/sock/mysql.sock tmpdir=/mysql/data/mysqldata/tmpdir
# 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
#add by tangyun performance_schema=0 event-scheduler=ON default-storage-engine=InnoDB character_set_server=utf8mb4 collation_server=utf8mb4_general_ci lower_case_table_names=1 explicit_defaults_for_timestamp=true
which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.
See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at
http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings
六、修改登錄密碼和檢查數(shù)據(jù)庫(kù)參數(shù) mysqladmin -u root -h tony7 password 'mysql' [root@tony7 ~]# mysql -uroot -pmysql -htony7 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 1 Server version: 5.6.28-log 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> use mysql 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> set password for 'root'@'localhost' = password('mysql'); Query OK, 0 rows affected (0.00 sec)
mysql> use mysql Database changed mysql> drop database test ; Query OK, 0 rows affected (0.00 sec)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec)
mysql> show global variables like '%slow%'; +---------------------------+------------------------------------------+ | Variable_name | Value | +---------------------------+------------------------------------------+ | log_slow_admin_statements | OFF | | log_slow_slave_statements | OFF | | slow_launch_time | 2 | | slow_query_log | ON | | slow_query_log_file | /mysql/data/mysqldata/log/slow-query.log | +---------------------------+------------------------------------------+ 5 rows in set (0.00 sec)
mysql> show global variables like '%log-bin%'; Empty set (0.00 sec)
mysql> show global variables like '%event%'; +--------------------------------------------------------+-------+ | Variable_name | Value | +--------------------------------------------------------+-------+ | binlog_rows_query_log_events | OFF | | event_scheduler | OFF | | log_bin_use_v1_row_events | OFF | | performance_schema_events_stages_history_long_size | 10000 | | performance_schema_events_stages_history_size | 10 | | performance_schema_events_statements_history_long_size | 10000 | | performance_schema_events_statements_history_size | 10 | | performance_schema_events_waits_history_long_size | 10000 | | performance_schema_events_waits_history_size | 10 | +--------------------------------------------------------+-------+ 9 rows in set (0.00 sec)
mysql> show full processlist; +----+------+-----------------+-------+---------+------+-------+-----------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+-------+---------+------+-------+-----------------------+ | 1 | root | localhost:24980 | mysql | Query | 0 | init | show full processlist | +----+------+-----------------+-------+---------+------+-------+-----------------------+ 1 row in set (0.00 sec)
mysql> set password for 'root'@'tony7' = password('mysql'); Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'127.0.0.1' = password('mysql'); Query OK, 0 rows affected (0.00 sec)