mysql

1.将mysql压缩包拷贝到/usr/local/目录下:
cd /usr/local
rz mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

2. 解压,并重命名
tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql

3.创建mysql用户组
groupadd mysql
useradd -r -g mysql mysql

4.进入目录,修改目录的拥有者
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

5.创建数据库存放文件夹和相关文件并修改权限
sudo mkdir -pv /data/mysqldb/3306/{logs,run,data}
sudo touch /data/mysqldb/3306/run/mysqld.pid
sudo touch /data/mysqldb/3306/logs/mysql-error.log
sudo chown -R mysql.mysql /data/mysqldb/
sudo chmod -R 777 /data/mysqldb

6.修改配置文件
cd /usr/local/mysql
sudo vim my.cnf

[client]
port=3306
socket=/data/mysqldb/3306/mysql.sock
default_character_set=utf8

[mysqld]
user=mysql
port=3306
socket=/data/mysqldb/3306/mysql.sock
basedir=/usr/local/mysql
datadir=/data/mysqldb/3306/data
pid-file=/data/mysqldb/3306/run/mysqld.pid
log-error=/data/mysqldb/3306/logs/mysql-error.log
character_set_server=utf8

[mysql]
socket=/data/mysqldb/3306/mysql.sock

[mysqldump]
socket=/data/mysqldb/3306/mysql.sock

[mysqladmin]
socket=/data/mysqldb/3306/mysql.sock

7.初始化mysql安装
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb/3306/data

8.把启动脚本放到开机初始化目录,添加开机启动mysql服务,复制启动服务脚本至/etc/init.d目录
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

9.开机启动mysql服务
sudo service mysqld start

10.配置环境变量
sudo vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile

11.修改root的密码
mysql -u root -p
mysql>set password for 'root'@'localhost'=password('admin');
mysql>quit

12.创建hive所需的账户和数据库
重新登录:
mysql -u root -p
输入密码admin即可登录
mysql>create user 'hive' identified by '123456';
mysql>CREATE DATABASE hive;

13.mysql授权
mysql>GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' IDENTIFIED BY '123456';
mysql>flush privileges;

14.配置Mysql服务远程可访问
mysql> grant all privileges on *.* to 'root'@'%' identified by "admin" with grant option;
mysql> flush privileges;

 
 

posted on 2021-01-07 14:13  happygril3  阅读(58)  评论(0编辑  收藏  举报

导航