mysql-5.7.x环境搭建-适用所有linux,centos
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
mysql-5.7-x安装
- 检查是否已安装过mariadb,若有便删除(linux系统自带的)
- rpm -qa | grep mariadb
- rpm -e --nodeps xxxxx
- 检查是否已安装过mysql,若有便删除(linux系统自带的)
- rpm -qa | grep mysql
- rpm -e --nodeps xxxxx
- 检查mysql组和用户是否存在,如无创建
- 检查
- cat /etc/group | grep mysql
- cat /etc/passwd |grep mysql
- 创建
- groupadd mysql
- useradd -r -g mysql mysql
- 检查
- 下载压缩包,解压,然后移动到appserver/mysql-5.7.24
- 下载
- wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
- 解压
- tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
- 移动
- mv mysql-5.7.24-linux-glibc2.12-x86_64 /appserver/mysql-5.7.24
- 下载
- 在mysql下添加data目录
- mkdir /appserver/mysql-5.7.24/data
- 更改mysql目录下所有的目录及文件夹所属组合用户
- chown -R mysql:mysql /appserver/mysql-5.7.24/
- chown -R mysql:mysql /appserver/mysql-5.7.24/data/
- chmod -R mysql /appserver/mysql-5.7.24/
- chmod -R mysql /appserver/mysql-5.7.24/data/
- 更改mysql安装文件夹mysql-5.7.24的权限
- chmod -R 755 /appserver/mysql-5.7.24/
- 安装libaio依赖包
- yum install libaio
- 初始化mysql,并基础控制台末尾输出的初始化密码
- 初始化
- /appserver/mysql-5.7.24/bin/mysqld --user=mysql --datadir=/appserver/mysql-5.7.24/data --basedir=/appserver/mysql-5.7.24 --initialize
- 默认密码示例
- A temporary password is generated for root@localhost: gFamcspKm2+u
- 初始化
- 修改mysql配置文件
- vi /appserver/mysql-5.7.24/support-files/mysql.server
- 修改前:
if test -z "$basedir" then basedir=/usr/local/mysql bindir=/usr/local/mysql/bin if test -z "$datadir" then datadir=/usr/local/mysql/data fi sbindir=/usr/local/mysql/bin libexecdir=/usr/local/mysql/bin else bindir="$basedir/bin" if test -z "$datadir" then datadir="$basedir/data" fi sbindir="$basedir/sbin" libexecdir="$basedir/libexec" fi
- 修改后
if test -z "$basedir" then basedir=/appserver/mysql-5.7.24 bindir=/appserver/mysql-5.7.24/bin if test -z "$datadir" then datadir=/appserver/mysql-5.7.24/data fi sbindir=/appserver/mysql-5.7.24/bin libexecdir=/appserver/mysql-5.7.24/bin else bindir="$basedir/bin" if test -z "$datadir" then datadir="$basedir/data" fi sbindir="$basedir/sbin" libexecdir="$basedir/libexec" fi
- :wq 保存退出
- 修改my.cnf文件 vim /etc/my.cnf
[client] no-beep socket =/appserver/mysql-5.7.24/mysql.sock # pipe # socket=0.0 port=3306 # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] # 支持emoji的utf8 default-character-set=utf8mb4 [mysqld] basedir=/appserver/mysql-5.7.24 datadir=/appserver/mysql-5.7.24/data port=3306 pid-file=/appserver/mysql-5.7.24/mysqld.pid # skip-grant-tables skip-name-resolve socket = /appserver/mysql-5.7.24/mysql.sock # 支持emoji的utf8 character-set-server=utf8mb4 default-storage-engine=INNODB explicit_defaults_for_timestamp = true # Server Id. server-id=1 max_connections=2000 query_cache_size=0 table_open_cache=2000 tmp_table_size=246M thread_cache_size=300 # 限定用于每个数据库线程的栈大小。默认设置足以满足大多数应用 thread_stack = 192k key_buffer_size=512M read_buffer_size=4M read_rnd_buffer_size=32M innodb_data_home_dir = /appserver/mysql-5.7.24/data innodb_flush_log_at_trx_commit=0 innodb_log_buffer_size=16M innodb_buffer_pool_size=256M innodb_log_file_size=128M innodb_thread_concurrency=128 innodb_autoextend_increment=1000 innodb_buffer_pool_instances=8 innodb_concurrency_tickets=5000 innodb_old_blocks_time=1000 innodb_open_files=300 innodb_stats_on_metadata=0 innodb_file_per_table=1 innodb_checksum_algorithm=0 back_log=80 flush_time=0 join_buffer_size=128M max_allowed_packet=1024M max_connect_errors=2000 open_files_limit=4161 query_cache_type=0 sort_buffer_size=32M table_definition_cache=1400 binlog_row_event_max_size=8K sync_master_info=10000 sync_relay_log=10000 sync_relay_log_info=10000 # 批量插入数据缓存大小,可以有效提高插入效率,默认为8M bulk_insert_buffer_size = 64M interactive_timeout = 120 wait_timeout = 120 log-bin-trust-function-creators=1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # include all files from the config directory !includedir /etc/my.cnf.d
- :wq 保存退出
- etc下面创建一个加.的my.cnf.文件
- mkdir /etc/my.cnf.
- touch /etc/my.cnf.
- mkdir /etc/my.cnf.d
- 做个软连接,启动服务
- ln -s /appserver/mysql-5.7.24/support-files/mysql.server /etc/init.d/mysql
- service mysql start
- 做个软链接,将安装目录下的mysql 放在/usr/bin 目录下,方便使用mysql命令
- ln -s /appserver/mysql-5.7.24/bin/mysql /usr/bin
- 登录msyql,输入密码(密码为步骤9初始化生成的密码)
- mysql -u root -p
- [Enter password:] xxxx
- 修改密码并开放远程
alter user 'root'@'localhost' identified by '此处密码自己设定'; use mysql; update user set user.Host='%' where user.User='root'; flush privileges; quit
- 设置开机自启动
- 将服务文件拷贝到init.d下
- cp /appserver/mysql-5.7.24/support-files/mysql.server /etc/init.d/mysqld
- 赋予可执行权限
- chmod +x /etc/init.d/mysqld
- chmod +x /etc/init.d/mysql
- 添加服务
- chkconfig --add mysqld
- 显示服务列表
- chkconfig --list
- 将服务文件拷贝到init.d下
- 如果报so库找不到错误,可执行如下命令
vi ~/.bashrc # 在末尾加入一行 export LD_LIBRARY_PATH=/appserver/mysql-5.7.24/lib:$LD_LIBRARY_PATH # 保存退出 :wq # 刷新 source ~/.bashrc
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献8条内容
所有评论(0)