下载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数据目录
重要:
此处需要注意记录生成的临时密码,如上文:GleB(RP14p<D 。如果在终端上没有显示,则就在配置文件配置的log_error参数制定的文件里,这里是/data/mysql/log/mysql-3700-error.log
三、数据库配置与启动
/export/local/mysql/bin/mysqld_safe --defaults-file=/etc/my_3700.cnf &
说明:--defaults-file 指定数据库配置文件
配置(/etc/my_3700.cnf)样本:
[client] port = 3700 #端口 socket = /tmp/mysql.sock #如果主机上运行了多个mysql,请注意区分开来 default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] 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 log-bin = mysql-bin innodb_flush_log_at_trx_commit = 1 binlog_ignore_db = mysql lower_case_table_names=1 #不区分大小写,其实都是转换成小写 max_connect_errors=1000 |
---|
四、以临时密码登录mysql,并重置密码
step 1: SET PASSWORD = PASSWORD('your new password'); step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; step 3: flush privileges; |
---|
五、授权
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'your password'; flush privileges; |
---|
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341