CentOS 7下安装MySQL
MySQL 是一种关系型数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL 所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。由于其社区版的性能卓越,搭配 PHP 和 Apache 可组成良好的开发环境。
- 官方镜像:http://dev.mysql.com/downloads/mirrors.html
- 中科大镜像:http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/
MySQL安装
el7(CentOS 7)
# rpm -qa | grep -i mysql //检查是否已安装MySQL,grep的-i选项表示匹配时忽略大小写
# rpm -qa | grep -i mariadb
mariadb-libs-5.5.52-1.el7.x86_64
# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps //卸载,–nodeps忽略依赖关系
# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar
# yum install -y perl-Module-Install.noarch numactl libaio
# tar -xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm //安装mysql客户端
# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm //安装mysql服务端
# rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm
# mysql -V
# vim /etc/my.cnf //配置my.cnf
# systemctl start mysqld //启动MySQL服务
# systemctl status mysqld //查看MySQL运行状态
# systemctl restart mysqld //重启MySQL服务
# grep "password" /var/log/mysqld.log //查看默认root用户密码
# /usr/bin/mysqladmin -uroot -p'YI#O1FgF,ptN' password '123456' //修改root用户密码
# /usr/bin/mysqladmin -u root -h appblog password '123456' //创建数据库
//设置开机启动
# systemctl enable mysqld
# systemctl daemon-reload
el6(CentOS 6)
# wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
# yum install -y perl-Module-Install.noarch numactl libaio
# tar -xf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
# rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm
# rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm
# rpm -ivh mysql-community-devel-5.7.21-1.el6.x86_64.rpm
# service mysqld start //启动MySQL服务
# service mysqld status //查看MySQL运行状态
# service mysqld restart //重启MySQL服务
# grep "password" /var/log/mysqld.log //查看默认root用户密码
# /usr/bin/mysqladmin -uroot -p'YI#O1FgF,ptN' password 'xxxxxx' //修改root用户密码
my.ini配置
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
port=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character_set_server=utf8 #设置MySQL服务器默认字符集
explicit_defaults_for_timestamp=true
[client]
default_character_set=utf8 #设置MySQL客户端默认字符集
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/12/centos7-install-mysql/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
1
二维码
打赏
海报
CentOS 7下安装MySQL
MySQL 是一种关系型数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL 所使用的……
文章目录
关闭
一位WordPress评论者