chown -R mysql:mysql /usr/local/mysql/data

  

一.MySQL版本选择的潜规则

	5.6:GA 6-12个月 并且小版本是偶数版
	5.7:GA 6-12个月 并且小版本是偶数版 5.7.17 以上版本,(MGR自带的高可用)

二.二进制安装MySQL
1.下载
[root@web01 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

2.解压
[root@oldboy ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz

3.移动到安装目录
[root@oldboy ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.40

4.软链接
[root@oldboy ~]# ln -s /usr/local/mysql-5.6.40 /usr/local/mysql

5.进入MySQL程序目录
[root@oldboy ~]# cd /usr/local/mysql

6.拷贝配置文件
[root@oldboy /usr/local/mysql/support-files]# cp my-default.cnf /etc/my.cnf

7.拷贝启动脚本
[root@oldboy /usr/local/mysql/support-files]# cp mysql.server /etc/init.d/mysqld

8.创建mysql用户
[root@oldboy /usr/local/mysql/support-files]# useradd mysql -s /sbin/nologin -M

9.进入mysql初始化目录
[root@oldboy /usr/local/mysql]# cd scripts/

10.安装依赖包
[root@oldboy /usr/local/mysql/scripts]# yum install -y libaio-devel

11.初始化mysql
[root@oldboy /usr/local/mysql/scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

12.添加环境变量
[root@oldboy /usr/local/mysql/scripts]# vi /etc/profile
export PATH="/usr/local/mysql/bin:$PATH"

13.加载环境变量
[root@oldboy /usr/local/mysql/scripts]# source /etc/profile

14.启停MySQL
启动:[root@oldboy /usr/local/mysql/scripts]# /etc/init.d/mysqld start
停止:[root@oldboy /usr/local/mysql/scripts]# /etc/init.d/mysqld stop

15.连接MySQL
[root@oldboy /usr/local/mysql/scripts]# mysql

16.设置MySQL密码
[root@oldboy /usr/local/mysql/scripts]# mysqladmin -uroot -p password '123'

17.修改密码
[root@oldboy /usr/local/mysql/scripts]# mysqladmin  -uroot -p123 password '1'

[root@oldboy /usr/local/mysql/scripts]# mysql -uroot -p1


三.MySQL的物理结构
MySQL的物理结构就是最底层的数据文件


四.开发规范
库名,表名,小写

  

03-27 01:01