MySQL之5.6版本安装

  • A+
所属分类:Blog Database MySQL

操作系统版本选择

CentOS/RHRL/ORACLE Linux 6.x x86_64发行版

建议磁盘分区规则(图片来源于知数堂培训)

MySQL之5.6版本安装

安装完系统后,要禁掉selinux:

#setenforce  0
#sed -i  's/SELINUX=.*/SELINUX=disabled/'  /etc/selinux/config

MySQL环境

MySQL之5.6版本安装 MySQL之5.6版本安装

或者选择搜狐国内镜像站,下载速度较快:http://mirrors.sohu.com/mysql

  • 下载二进制版本(也可以下载到自已的 home 下)
cd  /data
wget  http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
  • 下载 mysql 解压到/opt/mysql 下
cd  /opt/
mkdir  mysql
cd  mysql
tar  zxvf  /data/mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
  • 创建一个软连
cd  /usr/local/
ln  -s  /opt/mysql/mysql-5.6.23-linux-glibc2.5-x86_64  mysql
  • 创建用户
groupadd  mysql
useradd  -g  mysql  -s  /sbin/nologin  -d  /usr/local/mysql  mysql
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
  • 基于我们的配置文件定的环境,创建基本的目录
mkdir  /data/mysql
mkdir  /data/mysql/mysql3306
cd  /data/mysql/mysql3306/
mkdir  data
mkdir  logs
mkdir  tmp
chown  -R  mysql:mysql  /data/mysql/mysql3306
  • 创建/etc/my.cnf 配置文件

  • 做MySQL初始化

cd  /usr/local/mysql
./scripts/mysql_install_db   ###必须是在mysql家目录执行./scripts/mysql_install_db 不然提示找不到文件,
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql  ###(或者通过这种方式初始化)
[root@shunzi scripts]# ./mysql_install_db  --defaults-file=/etc/my.cnf
FATAL ERROR: Could not find ./bin/my_print_defaultsIf you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
[root@shunzi scripts]# cd ..
[root@shunzi mysql]# ./scripts/mysql_install_db --defaults-file=/etc/my.cnf
Installing MySQL system tables...2015-06-07 14:05:27 0 [Note] ./bin/mysqld (mysqld 5.6.24-log) starting as process 26418 ...
OKFilling help tables...2015-06-07 14:05:31 0 [Note] ./bin/mysqld (mysqld 5.6.24-log) starting as process 26465 ...
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/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h 192.168.11.156 password 'new-password'

Alternatively you can run:

/usr/local/mysql/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/local/mysql/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 <a href="http://bugs.mysql.com/">http://bugs.mysql.com/</a>

The latest information about MySQL is available on the web at

<a href="http://www.mysql.com/">http://www.mysql.com</a>

Support MySQL by buying support/licenses at <a href="http://shop.mysql.com/">http://shop.mysql.com</a>

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

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

小结:

  • 重点1:系统目录结构,好的系统目录结构对后期维护来说非常便利。附带了解下xfs文件系统
  • XFS一种高性能的日志文件系统,特别擅长处理大文件,同时提供平滑的数据传输。

下面是百度百科:https://baike.baidu.com/item/xfs?fr=aladdin

  • 重点2:/etc/my.cnf文件权限,默认是644。经简单测试my.cnf文件的权限不能有w权限。如果有写权限则不能初始化和启动数据库。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: