centos 7.5 安装 mysql 5.6

2022-05-06 20:48:05 浏览数 (1)

1、需求

CentOS7默认取消了MySQL源,可以安装MariaDB。不过有些人有些事需要去解释MariaDB和MySQL的关系等等,有时候干脆就直接安装MySQL了,不去解释他们之间的关系了。 因为MySQL5.7存在问题,需要在CentOS7下安装MySQL5.6

2、下载

https://dev.mysql.com/downloads/mysql/

https://dev.mysql.com/downloads/mysql/5.6.html#downloads

2021-08-28更新 https://downloads.mysql.com/archives/community/

3、上传与安装

(1)上传

代码语言:javascript复制
[root@qkl-dev01 ~]# ll
total 475548
-rw-------. 1 root root       1670 Jul 30 13:41 anaconda-ks.cfg
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Desktop
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Documents
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Downloads
-rw-r--r--. 1 root root       1882 Jul 30 13:45 initial-setup-ks.cfg
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Music
-rw-r--r--  1 root root  243456000 Aug  1 09:35 MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Pictures
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Public
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Templates
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Videos
[root@qkl-dev01 ~]#

(2)解压

代码语言:javascript复制
[root@qkl-dev01 ~]# tar -xvf MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar 
MySQL-embedded-5.6.41-1.el7.x86_64.rpm
MySQL-shared-5.6.41-1.el7.x86_64.rpm
MySQL-devel-5.6.41-1.el7.x86_64.rpm
MySQL-test-5.6.41-1.el7.x86_64.rpm
MySQL-server-5.6.41-1.el7.x86_64.rpm
MySQL-client-5.6.41-1.el7.x86_64.rpm
MySQL-shared-compat-5.6.41-1.el7.x86_64.rpm
[root@qkl-dev01 ~]# ll
total 475548
-rw-------. 1 root root       1670 Jul 30 13:41 anaconda-ks.cfg
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Desktop
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Documents
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Downloads
-rw-r--r--. 1 root root       1882 Jul 30 13:45 initial-setup-ks.cfg
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Music
-rw-r--r--  1 root root  243456000 Aug  1 09:35 MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--  1 7155 31415  20323896 Jun 18 15:14 MySQL-client-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415   3534356 Jun 18 15:14 MySQL-devel-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415  92714124 Jun 18 15:14 MySQL-embedded-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415  62416104 Jun 18 15:15 MySQL-server-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415   2105868 Jun 18 15:16 MySQL-shared-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415   2299664 Jun 18 15:16 MySQL-shared-compat-5.6.41-1.el7.x86_64.rpm
-rw-r--r--  1 7155 31415  60052128 Jun 18 15:16 MySQL-test-5.6.41-1.el7.x86_64.rpm
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Pictures
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Public
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Templates
drwxr-xr-x. 2 root root       4096 Jul 30 13:46 Videos

(3)安装

代码语言:javascript复制
[root@qkl-dev01 ~]# rpm -ivh MySQL-*.rpm
warning: MySQL-client-5.6.41-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-devel-5.6.41-1.el7         ################################# [ 14%]
   2:MySQL-client-5.6.41-1.el7        ################################# [ 29%]
   3:MySQL-test-5.6.41-1.el7          ################################# [ 43%]
   4:MySQL-embedded-5.6.41-1.el7      ################################# [ 57%]
   5:MySQL-shared-compat-5.6.41-1.el7 ################################# [ 71%]
   6:MySQL-shared-5.6.41-1.el7        ################################# [ 86%]
   7:MySQL-server-5.6.41-1.el7        ################################# [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2018-08-01 09:42:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-01 09:42:16 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-01 09:42:16 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 27721 ...
2018-08-01 09:42:16 27721 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-01 09:42:16 27721 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-01 09:42:16 27721 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-01 09:42:16 27721 [Note] InnoDB: Memory barrier is not used
2018-08-01 09:42:16 27721 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-01 09:42:16 27721 [Note] InnoDB: Using Linux native AIO
2018-08-01 09:42:16 27721 [Note] InnoDB: Not using CPU crc32 instructions
2018-08-01 09:42:16 27721 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-01 09:42:16 27721 [Note] InnoDB: Completed initialization of buffer pool
2018-08-01 09:42:16 27721 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-08-01 09:42:16 27721 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-08-01 09:42:16 27721 [Note] InnoDB: Database physically writes the file full: wait...
2018-08-01 09:42:16 27721 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-08-01 09:42:17 27721 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-08-01 09:42:17 27721 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-08-01 09:42:17 27721 [Warning] InnoDB: New log files created, LSN=45781
2018-08-01 09:42:17 27721 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-08-01 09:42:17 27721 [Note] InnoDB: Doublewrite buffer created
2018-08-01 09:42:17 27721 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-01 09:42:17 27721 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-01 09:42:17 27721 [Note] InnoDB: Foreign key constraint system tables created
2018-08-01 09:42:17 27721 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-08-01 09:42:17 27721 [Note] InnoDB: Tablespace and datafile system tables created.
2018-08-01 09:42:17 27721 [Note] InnoDB: Waiting for purge to start
2018-08-01 09:42:17 27721 [Note] InnoDB: 5.6.41 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2018-08-01 09:42:17 27721 [Note] Binlog end
2018-08-01 09:42:17 27721 [Note] InnoDB: FTS optimize thread exiting.
2018-08-01 09:42:17 27721 [Note] InnoDB: Starting shutdown...
2018-08-01 09:42:19 27721 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2018-08-01 09:42:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-01 09:42:19 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-01 09:42:19 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 27743 ...
2018-08-01 09:42:19 27743 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-01 09:42:19 27743 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-01 09:42:19 27743 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-01 09:42:19 27743 [Note] InnoDB: Memory barrier is not used
2018-08-01 09:42:19 27743 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-01 09:42:19 27743 [Note] InnoDB: Using Linux native AIO
2018-08-01 09:42:19 27743 [Note] InnoDB: Not using CPU crc32 instructions
2018-08-01 09:42:19 27743 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-01 09:42:19 27743 [Note] InnoDB: Completed initialization of buffer pool
2018-08-01 09:42:19 27743 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-01 09:42:19 27743 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-01 09:42:19 27743 [Note] InnoDB: Waiting for purge to start
2018-08-01 09:42:19 27743 [Note] InnoDB: 5.6.41 started; log sequence number 1625977
2018-08-01 09:42:19 27743 [Note] Binlog end
2018-08-01 09:42:19 27743 [Note] InnoDB: FTS optimize thread exiting.
2018-08-01 09:42:19 27743 [Note] InnoDB: Starting shutdown...
2018-08-01 09:42:21 27743 [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

【2021年11月23日重新安装】

代码语言:javascript复制
rpm -ivh MySQL-server-5.6.51-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.51-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.51-1.el7.x86_64.rpm
代码语言:javascript复制
[root@whtpjfscpt03 appuser]# ll
total 1314492
-rw-r--r-- 1 appuser appuser 254341120 Nov 23 09:11 MySQL-5.6.51-1.el7.x86_64.rpm-bundle.tar
-rw-r----- 1 appuser appuser  21606520 Jan  5  2021 MySQL-client-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser   3536604 Jan  5  2021 MySQL-devel-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser  93754464 Jan  5  2021 MySQL-embedded-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser  70091008 Jan  5  2021 MySQL-server-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser   2338300 Jan  5  2021 MySQL-shared-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser   2299660 Jan  5  2021 MySQL-shared-compat-5.6.51-1.el7.x86_64.rpm
-rw-r----- 1 appuser appuser  60704356 Jan  5  2021 MySQL-test-5.6.51-1.el7.x86_64.rpm
[root@whtpjfscpt03 appuser]# rpm -ivh MySQL-server-5.6.51-1.el7.x86_64.rpm
warning: MySQL-server-5.6.51-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-server-5.6.51-1.el7        ################################# [100%]
2021-11-23 09:30:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-23 09:30:59 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2021-11-23 09:30:59 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 99433 ...
2021-11-23 09:30:59 99433 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-11-23 09:30:59 99433 [Note] InnoDB: The InnoDB memory heap is disabled
2021-11-23 09:30:59 99433 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-11-23 09:30:59 99433 [Note] InnoDB: Memory barrier is not used
2021-11-23 09:30:59 99433 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-11-23 09:30:59 99433 [Note] InnoDB: Using Linux native AIO
2021-11-23 09:30:59 99433 [Note] InnoDB: Using CPU crc32 instructions
2021-11-23 09:30:59 99433 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2021-11-23 09:30:59 99433 [Note] InnoDB: Completed initialization of buffer pool
2021-11-23 09:30:59 99433 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2021-11-23 09:30:59 99433 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2021-11-23 09:30:59 99433 [Note] InnoDB: Database physically writes the file full: wait...
2021-11-23 09:30:59 99433 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2021-11-23 09:30:59 99433 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2021-11-23 09:30:59 99433 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-11-23 09:30:59 99433 [Warning] InnoDB: New log files created, LSN=45781
2021-11-23 09:30:59 99433 [Note] InnoDB: Doublewrite buffer not found: creating new
2021-11-23 09:30:59 99433 [Note] InnoDB: Doublewrite buffer created
2021-11-23 09:30:59 99433 [Note] InnoDB: 128 rollback segment(s) are active.
2021-11-23 09:30:59 99433 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-23 09:30:59 99433 [Note] InnoDB: Foreign key constraint system tables created
2021-11-23 09:30:59 99433 [Note] InnoDB: Creating tablespace and datafile system tables.
2021-11-23 09:30:59 99433 [Note] InnoDB: Tablespace and datafile system tables created.
2021-11-23 09:30:59 99433 [Note] InnoDB: Waiting for purge to start
2021-11-23 09:30:59 99433 [Note] InnoDB: 5.6.51 started; log sequence number 0
2021-11-23 09:30:59 99433 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2021-11-23 09:30:59 99433 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
A random root password has been set. You will find it in '/root/.mysql_secret'.
2021-11-23 09:30:59 99433 [Note] Binlog end
2021-11-23 09:30:59 99433 [Note] InnoDB: FTS optimize thread exiting.
2021-11-23 09:30:59 99433 [Note] InnoDB: Starting shutdown...
2021-11-23 09:31:01 99433 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2021-11-23 09:31:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-23 09:31:01 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2021-11-23 09:31:01 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 99457 ...
2021-11-23 09:31:01 99457 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-11-23 09:31:01 99457 [Note] InnoDB: The InnoDB memory heap is disabled
2021-11-23 09:31:01 99457 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-11-23 09:31:01 99457 [Note] InnoDB: Memory barrier is not used
2021-11-23 09:31:01 99457 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-11-23 09:31:01 99457 [Note] InnoDB: Using Linux native AIO
2021-11-23 09:31:01 99457 [Note] InnoDB: Using CPU crc32 instructions
2021-11-23 09:31:01 99457 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2021-11-23 09:31:01 99457 [Note] InnoDB: Completed initialization of buffer pool
2021-11-23 09:31:01 99457 [Note] InnoDB: Highest supported file format is Barracuda.
2021-11-23 09:31:01 99457 [Note] InnoDB: 128 rollback segment(s) are active.
2021-11-23 09:31:01 99457 [Note] InnoDB: Waiting for purge to start
2021-11-23 09:31:01 99457 [Note] InnoDB: 5.6.51 started; log sequence number 1625977
2021-11-23 09:31:01 99457 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2021-11-23 09:31:01 99457 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2021-11-23 09:31:01 99457 [Note] Binlog end
2021-11-23 09:31:01 99457 [Note] InnoDB: FTS optimize thread exiting.
2021-11-23 09:31:01 99457 [Note] InnoDB: Starting shutdown...
2021-11-23 09:31:03 99457 [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

[root@whtpjfscpt03 appuser]# rpm -ivh MySQL-devel-5.6.51-1.el7.x86_64.rpm
warning: MySQL-devel-5.6.51-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-devel-5.6.51-1.el7         ################################# [100%]
[root@whtpjfscpt03 appuser]# rpm -ivh MySQL-client-5.6.51-1.el7.x86_64.rpm
warning: MySQL-client-5.6.51-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-client-5.6.51-1.el7        ################################# [100%]
[root@whtpjfscpt03 appuser]#

4、初步配置

(1)复制配置文件

代码语言:javascript复制
[root@qkl-dev01 ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf

(2)初始化密码

代码语言:javascript复制
[root@qkl-dev01 ~]# /usr/bin/mysql_install_db
Installing MySQL system tables...2018-08-01 09:43:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-01 09:43:19 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-01 09:43:19 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 27787 ...
2018-08-01 09:43:19 27787 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-01 09:43:19 27787 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-01 09:43:19 27787 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-01 09:43:19 27787 [Note] InnoDB: Memory barrier is not used
2018-08-01 09:43:19 27787 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-01 09:43:19 27787 [Note] InnoDB: Using Linux native AIO
2018-08-01 09:43:19 27787 [Note] InnoDB: Not using CPU crc32 instructions
2018-08-01 09:43:19 27787 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-01 09:43:19 27787 [Note] InnoDB: Completed initialization of buffer pool
2018-08-01 09:43:19 27787 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-01 09:43:19 27787 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-01 09:43:19 27787 [Note] InnoDB: Waiting for purge to start
2018-08-01 09:43:19 27787 [Note] InnoDB: 5.6.41 started; log sequence number 1625987
2018-08-01 09:43:19 27787 [Note] Binlog end
2018-08-01 09:43:19 27787 [Note] InnoDB: FTS optimize thread exiting.
2018-08-01 09:43:19 27787 [Note] InnoDB: Starting shutdown...
2018-08-01 09:43:21 27787 [Note] InnoDB: Shutdown completed; log sequence number 1625997
OK

Filling help tables...2018-08-01 09:43:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-01 09:43:21 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-01 09:43:21 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 27810 ...
2018-08-01 09:43:21 27810 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-01 09:43:21 27810 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-01 09:43:21 27810 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-01 09:43:21 27810 [Note] InnoDB: Memory barrier is not used
2018-08-01 09:43:21 27810 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-01 09:43:21 27810 [Note] InnoDB: Using Linux native AIO
2018-08-01 09:43:21 27810 [Note] InnoDB: Not using CPU crc32 instructions
2018-08-01 09:43:21 27810 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-01 09:43:21 27810 [Note] InnoDB: Completed initialization of buffer pool
2018-08-01 09:43:21 27810 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-01 09:43:21 27810 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-01 09:43:21 27810 [Note] InnoDB: Waiting for purge to start
2018-08-01 09:43:21 27810 [Note] InnoDB: 5.6.41 started; log sequence number 1625997
2018-08-01 09:43:21 27810 [Note] Binlog end
2018-08-01 09:43:21 27810 [Note] InnoDB: FTS optimize thread exiting.
2018-08-01 09:43:21 27810 [Note] InnoDB: Starting shutdown...
2018-08-01 09:43:23 27810 [Note] InnoDB: Shutdown completed; log sequence number 1626007
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h qkl-dev01 password 'new-password'

Alternatively you can run:

  /usr/bin/mysql_secure_installation

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

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

(3)启动数据库

代码语言:javascript复制
[root@qkl-dev01 ~]# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/qkl-dev01.err'.
 SUCCESS! 

(4)查看随机密码

代码语言:javascript复制
[root@qkl-dev01 ~]# cat /root/.mysql_secret
# The random password set for the root user at Wed Aug  1 09:42:17 2018 (local time): FovXjdiATu9EhUGo

(5)修改密码

代码语言:javascript复制
[root@qkl-dev01 ~]# mysql -uroot -pFovXjdiATu9EhUGo
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 6
Server version: 5.6.41

Copyright (c) 2000, 2018, 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');    #设置密码为123456
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

(6)重新登录

代码语言:javascript复制
[root@qkl-dev01 ~]# mysql -uroot -p123456
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 7
Server version: 5.6.41 MySQL Community Server (GPL)

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

(7)修改root

代码语言:javascript复制
mysql> select host,user,password from mysql.user;
 ------------ ------ ------------------------------------------- 
| host       | user | password                                  |
 ------------ ------ ------------------------------------------- 
| localhost  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| qkl_uat01 | root | *02B4C4C5E713E8E381716C2DB97908A14B5CFDCE |
| 127.0.0.1  | root | *02B4C4C5E713E8E381716C2DB97908A14B5CFDCE |
| ::1        | root | *02B4C4C5E713E8E381716C2DB97908A14B5CFDCE |
 ------------ ------ ------------------------------------------- 
4 rows in set (0.00 sec)
mysql> update mysql.user set password=password('123456') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4  Changed: 3  Warnings: 0

mysql> select host,user,password from mysql.user;
 ------------ ------ ------------------------------------------- 
| host       | user | password                                  |
 ------------ ------ ------------------------------------------- 
| localhost  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| qkl_uat01 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 127.0.0.1  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| ::1        | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
 ------------ ------ ------------------------------------------- 
4 rows in set (0.00 sec)

mysql> update mysql.user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user,password from mysql.user;
 ------------ ------ ------------------------------------------- 
| host       | user | password                                  |
 ------------ ------ ------------------------------------------- 
| %          | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| qkl_uat01 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 127.0.0.1  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| ::1        | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
 ------------ ------ ------------------------------------------- 
4 rows in set (0.00 sec)

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

mysql> exit
Bye

(8)开机启动

代码语言:javascript复制
[root@qkl_uat01 ~]# chkconfig mysql on
[root@qkl_uat01 ~]# chkconfig --list | grep mysql

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysql          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@qkl_uat01 ~]# 

0 人点赞