新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
初始操作mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
湘桥网站建设公司创新互联建站,湘桥网站设计制作,有大型网站制作公司丰富经验。已为湘桥近1000家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的湘桥做网站的公司定做!
# 解压
tar xzvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
# 迁移到指定目录
mv mysql-5.7.11-linux-glibc2.5-x86_64 /data/mysql
# 根目录创建文件夹
cd /data/mysql
mkdir arch data tmp
创建mysql的配置文件vi /etc/my.cnf
[client]
port = 3306
socket = /data/mysql/data/mysql.sock
[mysqld]
port = 3306
socket = /data/mysql/data/mysql.sock
skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M
table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600
# Try number of CPU's*2 for thread_concurrency
#thread_concurrency = 32
#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED
server-id = 1
basedir = /data/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/data/hostname.pid
#open performance schema
log-warnings
sysdate-is-now
binlog_format = MIXED
log_bin_trust_function_creators=1
log-error = /data/mysql/data/hostname.err
log-bin=/data/mysql/arch/mysql-bin
#other logs
#general_log =1
#general_log_file = /data/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/data/mysql/data/slow_log.err
#for replication slave
#log-slave-updates
#sync_binlog = 1
#for innodb options
innodb_data_home_dir =/data/mysql/data/
innodb_data_file_path = ibdata1:500M:autoextend
innodb_log_group_home_dir = /data/mysql/arch
innodb_log_files_in_group = 4
innodb_log_file_size = 1G
#生产上 机械硬盘 sata盘 5000r转 7200 10000 15000 ==>ssd 生产
# innodb_buffer_pool_size 调大 16G,一般是8G (调优的时候一般是这个地方)
innodb_buffer_pool_size = 16G
#innodb_additional_mem_pool_size = 50M
innodb_log_buffer_size = 200M
innodb_lock_wait_timeout = 100
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 1
innodb_locks_unsafe_for_binlog=1
#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on
#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[mysqlhotcopy]
interactive-timeout
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
创建用户组和用户# 创建用户组和用户
groupadd -g 101 dba
useradd -u 514 -g dba -G root -d /data/mysql mysqladmin
# copy环境变量配置文件至mysqladmin用户的home目录中,为以下步骤配置个人环境变量
cp /etc/skel/.* /data/mysql
su - mysqladmin (这样进去的环境开头不是-bash这些)
# 配置环境变量及切换mysqladmin用户后的路径
vi /data/mysql/.bash_profile
替换为
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/.local/bin:$HOME/bin
#export PATH
export MYSQL_BASE=/data/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
unset UAERNAME
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1
# 赋予权限
chown mysqladmin:dba /etc/my.cnf
chmod 640 /etc/my.cnf
chown -R mysqladmin:dba /data/mysql
chmod -R 755 /data/mysql
配置服务及开机自启动
cd /data/mysql
# 将服务名拷贝到init.d下,并重命名mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysql
# 赋予可执行权限
chmod +x /etc/rc.d/init.d/mysql
# 删除服务
chkconfig --del mysql
# 添加服务
chkconfig --add mysql
chkconfig --level 345 mysql on
# 安装libaio及安装mysql的初始db
yum -y install libaio
su - mysqladmin
# 初始化mysql
bin/mysqld --defaults-file=/etc/my.cnf --user=mysqladmin --basedir=/data/mysql/ --datadir=/data/mysql/data/ --initialize
修改密码# 查看临时密码(把零食密码记录一下)
cd data
ll
cat hostname.err |grep password
>>>JI8gWBlKbs,&
# 启动(到mysql主目录下)
/data/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
# 测试mysql
service mysql status
service mysql restart
# 登录及修改临时用户密码(-p后面千万别有空格)
mysql -uroot -p'前面的临时密码'
show databases; (报错说需要重置密码)
# 重置密码
alter user root@localhost identified by 'mysql!@#';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql!@#';
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧