mariadb linux二进制tar包安装

下载

地址为:https://downloads.mariadb.org/

释放安装包 假设安装位置是/usr/local/mariadb 包名为:mariadb-10.1.19-linux-x86_64.tar.gz

tar -xvzf mariadb-10.1.19-linux-x86_64.tar.gz

mv mariadb-10.1.19-linux-x86_64 /usr/local/mariadb/

cd /usr/local/mariadb

 

相关配置

备份原有mysql配置: mv /etc/my.cnf /etc/my.cnf.bak

复制配置文件: cp support-files/my-huge.cnf /etc/my.cnf 

编辑配置文件: vim /etc/my.cnf 在[mysqld]块中添加basedir全局目录将默认的数据目录,日志目录,pid文件都放置在basedir目录下,配置如下:

basedir = /usr/local/soft/mariadb/mariadb-10.2.9-linux-x86_64

skip_name_resolve = ON  

innodb_file_per_table = ON

 

创建用户

初次安装,要创建mysql用户和组,并给当前目录赋予权限:

groupadd mysql

useradd -r -g mysql -s /sbin/nologin mysql

cd /usr/local/soft/mariadb/mariadb-10.2.9-linux-x86_64/

chown -R mysql .

chgrp -R mysql .

然后执行初始化安装:scripts/mysql_install_db --user=mysql 

调整权限:

chown -R root .

chown -R mysql data/

 

启动脚本

/usr/local/soft/mariadb/mariadb-10.2.9-linux-x86_64/bin/mysqld_safe --user=mysql & 

添加mysql到系统服务目录: cp /usr/local/soft/mariadb/mariadb-10.2.9-linux_x86_64/support-files/mysql.server /etc/init.d/mysqld 

如果是之前安装过mysql,那么现在就已经启动了,第一次安装需要手动启动务: /etc/init.d/mysqld start 

添加mysqld到系统服务,随系统一起启动: chkconfig mysqld on 

查看mysql服务运行状态: systemctl status mysqld.service

 

设置数据库允许远程链接

mysql -u root -proot 

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

操作完后切记执行以下命令刷新权限 

FLUSH PRIVILEGES 

 

 

posted on 2017-11-01 13:36  baogechen  阅读(1421)  评论(0)    收藏  举报

导航