二进制安装mysql5.6(参考)

########数据库安装#######
1.1. 上传安装文件压缩包: mysql-5.6.38-linux-glibc2.12-x86_64.tar
1.2. 解压并修改文件名
tar -xvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.6.38-linux-glibc2.12-x86_64 /application/
cd /application/
mv mysql-5.6.38-linux-glibc2.12-x86_64 mysql56

1.3. 创建组和用户及密码
#groupadd mysql
#useradd mysql -g mysql
mkdir -p /application/mysql56/data
chown -R mysql:mysql /application/mysql56
#passwd mysql

mkdir -p /var/log/mariadb/
cd  /var/log/mariadb/
touch mariadb.log
chown mysql.mysql mariadb.log


1.4. 数据库初始化
/application/mysql56/scripts/mysql_install_db --user=mysql --basedir=/application/mysql56 --datadir=/application/mysql56/data


1.5 修改 mysql.server 参数
路径:/application/mysql56/support-files/mysql.server
修改 mysql.server 的基本和数据存放路径(basedir,datadir)

1.6 配置 my.cnf 文件(供参数)
路径:base_dir 下
#/application/mysql56/my.cnf

port = 3306
socket = /application/mysql56/data/mysql13326.sock
federated
basedir=/application/mysql56
datadir=/application/mysql56/data
innodb_data_home_dir = /application/mysql56/data
innodb_log_group_home_dir = /application/mysql56/data

log-bin=mysql-bin
server-id = 1

lower_case_table_names=1
relay_log_purge=0
long_query_time = 1
event_scheduler = ON
binlog_format=ROW

innodb_log_files_in_group = 1
innodb_max_dirty_pages_pct = 90

innodb_buffer_pool_size=1G
innodb_log_file_size = 25M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 120

character_set_server = utf8

expire_logs_days=3

[mysqld_safe]
log-error = /var/log/mariadb/mariadb.log

涉及修改内容:server-id,相关的基本存储路径和数据存储路径,端口号,socket 文件路径,如果已有/data/auto.cnf则删除 
日志路径:/var/log/mariadb/mariadb.log

1.7 启动关闭服务
/application/mysql56/support-files/mysql.server start|stop|restart
1.8 修改 mysql 用户 root 密码
修 改 密 码 :  /application/mysql56/bin/mysqladmin  -u  root  password  'root123456'  -h127.0.0.1 -P3306
修改成功且会有一个提示:
Warning: Using a password on the command line interface can be insecure.
1.8 完成

修改root密码:
mysql -uroot -p -P3306 -h127.0.0.1

select user,password,host from mysql.user;
delete from mysql.user  where user='';
delete from  mysql.user where password ='' and user='root';

 

1.9#mysql 加入到service服务中
cp /application/mysql56/support-files/mysql.server /etc/rc.d/init.d/
cd /etc/rc.d/init.d/
mv  mysql.server mysql

 

2.0 创建开发用户,查询只读用户

#开发用户

create user 'developer'@'%';
SET PASSWORD FOR 'developer'@'%' = PASSWORD('xxxxxx');
grant   select   ,update,delete,insert  ,create,CREATE ROUTINE,CREATE TEMPORARY TABLES,CREATE VIEW,EXECUTE,FILE,INDEX,LOCK TABLES,SHOW DATABASES  
,SHOW VIEW,TRIGGER on *.* to 'developer'@'%';
flush privileges;

 

#查询用户

create user 'db_select'@'%';
SET PASSWORD FOR 'db_select'@'%' = PASSWORD('xxxxxxxx');
grant select,process  on *.* to 'db_select'@'%';
flush privileges;

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值