MySQL初始化安装
下载MySQL编译后的包,解压到/export/local/ (具体根据自己使用情况而定)下
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、成都做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的元江县网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
一、添加mysql用户和用户组
1、groupadd mysql 2、useradd -r -g mysql mysql |
---|
二、mysql数据目录初始化
1、mkdir /data/mysql/data 2、chown -R mysql:mysql /data/mysql/data 3、/export/local/mysql/bin/mysqld --defaults-file=/etc/my_3700.cnf --initialize --user=mysql --basedir=/export/local/mysql --datadir=/data/mysql/data |
---|
##初始化
说明:--basedir 为mysql安装路径,这里是安装在/export/local/目录下
--datadir 为mysql数据目录
重要: 三、数据库配置与启动 [client] [mysql] [mysqld] log-bin = mysql-bin lower_case_table_names=1 #不区分大小写,其实都是转换成小写 四、以临时密码登录mysql,并重置密码 五、授权 GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'your password'; flush privileges;
此处需要注意记录生成的临时密码,如上文:GleB(RP14p
/export/local/mysql/bin/mysqld_safe --defaults-file=/etc/my_3700.cnf &
说明:--defaults-file 指定数据库配置文件
配置(/etc/my_3700.cnf)样本:
port = 3700 #端口
socket = /tmp/mysql.sock #如果主机上运行了多个mysql,请注意区分开来
default-character-set=utf8
default-character-set=utf8
server_id = 13000
port = 3700
user = mysql
character-set-server = utf8mb4
default_storage_engine = innodb
log_timestamps = SYSTEM
socket = /tmp/mysql.sock #如果主机上运行了多个mysql,请注意区分开来
basedir = /export/local/mysql #数据库安装目录
datadir = /data/mysql/data #数据库数据目录
pid-file = /data/mysql/data/mysql.pid #PID文件路径
max_connections = 10000
max_connect_errors = 10000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
lower_case_table_names = 1
innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path = ibdata1:10M:autoextend
slow_query_log = 1
long_query_time = 1
log_error = /data/mysql/log/mysql-3700-error.log #日志路径
slow_query_log_file = /data/mysql/log/mysql-3700-slow.log
transaction-isolation=Read-Committed
innodb_flush_log_at_trx_commit = 1
binlog_ignore_db = mysql
max_connect_errors=1000step 1: SET PASSWORD = PASSWORD('your new password');
step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
step 3: flush privileges;
当前题目:MySQL初始化安装
网站路径:http://cdiso.cn/article/posjhc.html