005-LAMP_MySQL binary installation

005-LAMP_MySQL binary installation

安装方式:

(1) rpm包;

(a) 由OS的发行商提供;比如redhat默认使用了innodb而默认却是myisam
(b) 程序官方提供;

(2) 源码包;

(3) 通用二进制格式的程序包;

binary install MariaDB(CentOS 7)

官方的二进制安装方法直接在压缩文件中,其文件名为INSTALL-BINARY

1 卸载CentOS 7上yum安装的mariadb-server

[root@husa ~]# systemctl stop mariadb.service  
[root@husa ~]# yum remove mariadb-server

2 下载mariadb二进制格式安装包

[root@husa ~]# ls
99.sh            a.sh      latest.tar.gz         mariadb-5.5.46-linux-x86_64.tar.gz  show.sh
anaconda-ks.cfg  grub.bak  linux-3.10.67.tar.xz  service.sh                          wordpress-4.4.1.tar.gz

3 解压二进制包至/etc/local目录中

[root@husa ~]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/

4 创建软链接

3中解压缩后的mariadb的文件名为:mariadb-5.5.46-linux-x86_64,因此创建软链接

[root@husa local]# ln -sv mariadb-5.5.46-linux-x86_64 mysql
"mysql" -> "mariadb-5.5.46-linux-x86_64"

这里需要改名为mysql而不是mariadb,因为其各种路径要求仍然是mysql

5 创建mysql用户和组,使mariadb以创建的系统用户身份运行

由于之前的CentOS 7上存在mariadb数据库,因此也就会存在mysql用户和组。

5.1 删除mysql用户和组

[root@husa local]# userdel mysql
[root@husa local]# cat /etc/group |grep mysql  
[root@husa local]#  #删除用户的同时也删除了组 

5.2 创建mysql用户和组

[root@husa local]# useradd -r -u 27 mysql   #-r表示创建系统用户
[root@husa local]# cat /etc/passwd | grep mysql                          
mysql:x:27:27::/home/mysql:/bin/bash
[root@husa local]# cat /etc/group |grep mysql
mysql:x:27:
[root@husa local]# id mysql
uid=27(mysql) gid=27(mysql) 组=27(mysql)

5.3 修改/usr/local/mysql目录下的所有文件的属主属组

[root@husa local]# cd mysql
[root@husa mysql]# ls
bin      COPYING.LESSER  EXCEPTIONS-CLIENT  INSTALL-BINARY  man         README   share      support-files
COPYING  data            include            lib             mysql-test  scripts  sql-bench
[root@husa mysql]# chown -R root:mysql ./*

6 创建文件系统作为mariadb的数据存放目录

此处以一个目录模拟

[root@husa mysql]# mkdir -pv /databank/mysql
mkdir: 已创建目录 "/databank"
mkdir: 已创建目录 "/databank/mysql"

[root@husa mysql]# chown -R mysql:mysql /databank   #修改目录属主属组使mysql程序有读写权限

7 给二进制mariadb提供配置文件

[root@husa mysql]# ls
bin      COPYING.LESSER  EXCEPTIONS-CLIENT  INSTALL-BINARY  man         README   share      support-files
COPYING  data            include            lib             mysql-test  scripts  sql-bench
[root@husa mysql]# cd support-files/
[root@husa support-files]# ls
binary-configure  my-huge.cnf             my-large.cnf   my-small.cnf         mysql-log-rotate  SELinux
magic             my-innodb-heavy-4G.cnf  my-medium.cnf  mysqld_multi.server  mysql.server

[root@husa support-files]# mkdir /etc/mysql
[root@husa support-files]# cp my-large.cnf /etc/mysql/my.cnf

ffot
创建/etc/mysql目录并把support目录下的样本配置文件复制到上上述目录且名字为my.cnf,在这个目录中,mysql也可以读取配置文件

修改上述配置文件,主要指定下面两个字段

[mysqld]    #一定要放在这一段中
datadir = /databank/mysql   #指定目录
skip_name_resolve = ON      #不反解IP
innodb_file_per_table = ON

配置mysqld服务

[root@husa support-files]# cp mysql.server /etc/init.d/mysqld
[root@husa support-files]# chown root:root /etc/init.d/mysqld
[root@husa support-files]# chkconfig --add /etc/init.d/mysqld   #添加mysqld服务到相应的运行级别

8 配置元数据

[root@husa mysql]# scripts/mysql_install_db --user=mysql --datadir=/databank/mysql
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 MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h husa.hust password 'new-password'

Alternatively you can run:
'./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 MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/databank/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from MariaDB
Corporation Ab. You can contact us about this at sales@mariadb.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

[root@husa mysql]# ls /databank/mysql/
aria_log.00000001  aria_log_control  mysql  mysql-bin.000001  mysql-bin.000002  mysql-bin.index  performance_schema  test

# 查看数据目录发现有了mysql的各种数据库test、performance_schema等

9 启动mysqld服务

[root@husa support-files]# service mysqld start
Starting MySQL.. SUCCESS!   #成功启动了mysql

[root@husa mysql]# ss -nlt 
State      Recv-Q Send-Q                             Local Address:Port                               Peer Address:Port 
LISTEN     0      50                                             *:3306                                          *:*   

#查看端口发现3306已经启动起来了。

mysql配置文件读取顺序

OS Vendor提供mariadb rpm包安装的服务的配置文件查找次序

/etc/mysql/my.cnf  --> /etc/my.cnf  --> --default-extra-file=/PATH/TO/CONF_FILE  --> ~/.my.cnf

通用二进制格式安装的服务程序其配置文件查找次序

/etc/my.cnf  --> /etc/mysql/my.cnf  --> --default-extra-file=/PATH/TO/CONF_FILE  --> ~/.my.cnf

获取其读取次序的方法

mysqld  --verbose  --help
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值