安装环境:
操作系统 | MySQL版本 |
---|---|
CentOS release 6.7 (Final) | MySQL-5.6.32 |
安装步骤:
1、MySQL官网下载mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz。
2、解压mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz。
[lucy@min software]$ tar xf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz
[lucy@min software]$ mv mysql-5.6.32-linux-glibc2.5-x86_64 ../mysql5632
[lucy@min mysql5632]$ pwd
/home/lucy/mysql5632
3、配置my.cnf。
[lucy@min mysql5632]$ cp support-files/my-default.cnf my.cnf
[lucy@min mysql5632]$ egrep -v "^#|^$" my.cnf
[mysqld]
basedir = /home/lucy/mysql5632
datadir = /home/lucy/mysql5632/data
port = 9106
socket = /home/lucy/mysql5632/socket/mysql.sock
pid-file = /home/lucy/mysql5632/pid/mysql.pid
log-error = /home/lucy/mysql5632/logs/mysql.log
user = lucy
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[lucy@min mysql5632]$ mkdir socket pid logs
[lucy@min mysql5632]$ ls -ld socket/ pid/ logs/
drwxrwxr-x 2 lucy lucy 6 Aug 20 21:36 logs/
drwxrwxr-x 2 lucy lucy 6 Aug 20 21:36 pid/
drwxrwxr-x 2 lucy lucy 6 Aug 20 21:36 socket/
4、初始化MySQL。
[lucy@min mysql5632]$ scripts/mysql_install_db --defaults-file=my.cnf
Installing MySQL system tables...2016-08-20 21:39:31 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-20 21:39:31 0 [Note] ./bin/mysqld (mysqld 5.6.32) starting as process 15831 ...
OK
Filling help tables...2016-08-20 21:39:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-20 21:39:41 0 [Note] ./bin/mysqld (mysqld 5.6.32) starting as process 15880 ...
OK
......
初始化过程中出现两个“OK”则表示初始化成功。
5、启动MySQL。
[lucy@min mysql5632]$ bin/mysqld_safe --defaults-file=my.cnf &
[lucy@min mysql5632]$ ps aux | grep mysql
lucy 16368 0.0 0.3 113252 1588 pts/1 S 21:43 0:00 /bin/sh bin/mysqld_safe --defaults-file=my.cnf
lucy 16533 0.9 22.1 633108 109568 pts/1 Sl 21:43 0:00 /home/lucy/mysql5632/bin/mysqld --defaults-file=my.cnf --basedir=/home/lucy/mysql5632 --datadir=/home/lucy/mysql5632/data --plugin-dir=/home/lucy/mysql5632/lib/plugin --log-error=/home/lucy/mysql5632/logs/mysql.log --pid-file=/home/lucy/mysql5632/pid/mysql.pid --socket=/home/lucy/mysql5632/socket/mysql.sock --port=9106
lucy 16680 0.0 0.1 112644 976 pts/1 R+ 21:43 0:00 grep --color=auto mysql
6、连接MySQL。
[lucy@min mysql5632]$ bin/mysql -h127.0.0.1 -uroot -P9106
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 MySQL Community Server (GPL)
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>
首次安装好MySQL,使用root用户连接MySQL时默认密码为空,连接上去后可自行修改密码。