服务器部署、配置mysql【centos】

创建账户
添加用户
useradd alexs
添加密码
passwd alexs
wits1730960
创建用户组
groupadd developer
更改用户组
usermod -g developer alexs

1,上传包
cd /usr/local/
sudo mkdir mysql
cd mysql
 
2,tar -zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz #解压压缩包
 
3 , mv mysql-5.6.29-linux-glibc2.5-x86_64 /usr/local/mysql #移动位置
 
----
groupadd mysql
useradd -r -g mysql mysql -d /usr/local/mysql
passwd mysql
sql2015
chown -R mysql:mysql /usr/local/mysql
将/usr/local/mysql目录下归属到mysql用户及mysql组
chown 命令 更改某个文件或目录的属主和属组。
-R : 递归式地改变指定目录及其下的所有子目录和文件的拥有者。
-v : 显示chown命令所做的工作。
mysql:mysql,第一个mysql是用户名,第二个mysql是组名
 
----
 
4 , /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data #安装
 
5 , cd /usr/local/mysql #配置
cp my.cnf my.cnf.bak #备份my.cnf
vim my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
 
[mysqld]
 
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
 
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
 
# These are commonly set, remove the # and set as required.
 basedir = /usr/local/mysql
 datadir = /usr/local/mysql/data
 port = 3306
# server_id = .....
# socket = .....
 
character_set_server = utf8mb4
 
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
 
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
 
max_allowed_packet=20M
 
#
# * Query Cache Configuration
#
query_cache_limit       = 10M
query_cache_size        = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 
[mysql]
default-character-set = utf8mb4
 
6 , cp my.cnf /etc/my.cnf #系统替换文件
 
7 , cd /usr/local/mysql/support-files/
cp mysql.server /etc/init.d/mysql #配置系统启动
 
8 , chkconfig --add mysql #开机启动
 
9 , chkconfig mysql on #开机启动开启
 
10 , vim /etc/profile #配置环境
在最下面追加
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
 
11 , source /etc/profile #使环境生效
 
12 , service mysql start #开启mysql
 
13 , /usr/local/mysql/bin/mysqladmin -u root password 'alexs2015' #更改root密码
 
14 , /usr/local/mysql/bin/mysql -u root -p #连接数据库
wits2015
 
15 , GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'witsSQL2016' WITH GRANT OPTION; #远程连接权限
 
16 , FLUSH PRIVILEGES; #刷新权限
 
17 , exit #退出
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值