赞
踩
环境说明:阿里云ECS,2核2G(新老用户同享,仅需99/年),X86架构,CentOS 7.9操作系统。
- # 检查当前服务器是否安装mariadb
- rpm -qa |grep mariadb
- # 卸载已安装的mariadb(注意:mariadb-libs-5.5.68-1.el7.x86_64是上一条命令输出结果)
- rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
安装库(支持MySQL实现异步IO操作)
yum install -y libaio
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.35-1.el7.x86_64.rpm-bundle.tar
tar -xvf /tmp/mysql-8.0.35-1.el7.x86_64.rpm-bundle.tar
- rpm -ivh mysql-community-common-8.0.35-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-8.0.35-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-8.0.35-1.el7.x86_64.rpm
- rpm -ivh mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-8.0.35-1.el7.x86_64.rpm
- #慢查询配置
- slow_query_log=ON
- slow_query_log_file=/var/log/mysql_slow_query.log
- long_query_time=1
-
- #设置默认存储引擎
- default-storage-engine=INNODB
- #修改默认编码
- character-set-server=utf8mb4
- collation-server=utf8mb4_general_ci
- #表名和字段名不区分大小写
- #lower_case_table_names=1
- #设置MySQL运行端口
- port=11113
- #MySQL允许最大的进程连接数
- max_connections = 3000
- #设置在网络传输中一次消息传输量的最大值
- max_allowed_packet = 32M
-
- [client]
- #修改默认编码
- default-character-set=utf8mb4
- #以下两种初始化方式选择一个就好
- #不生成root账号密码
- mysqld --initialize-insecure --user=mysql
- #自动生成root账号密码
- mysqld --initialize --user=mysql
- #如果自动生成了root账号密码,那么可以mysql日志中查看初始密码
- cat /var/log/mysqld.log
- # 启动MySQL
- systemctl start mysqld
- # 将MySQL设置为开机自启动
- systemctl enable mysqld
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxxxxx';
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。