linux版本mysql安装
1先检查有没有安装mariadb,有的话将其卸载,不然会和mysql冲突。
yum list | grep mariadb
mariadb-libs.x86_64 1:5.5.68-1.el7 @anaconda
mariadb.x86_64 1:5.5.68-1.el7 base
mariadb-bench.x86_64 1:5.5.68-1.el7 base
mariadb-devel.i686 1:5.5.68-1.el7 base
mariadb-devel.x86_64 1:5.5.68-1.el7 base
mariadb-embedded.i686 1:5.5.68-1.el7 base
mariadb-embedded.x86_64 1:5.5.68-1.el7 base
mariadb-embedded-devel.i686 1:5.5.68-1.el7 base
mariadb-embedded-devel.x86_64 1:5.5.68-1.el7 base
mariadb-libs.i686 1:5.5.68-1.el7 base
mariadb-server.x86_64 1:5.5.68-1.el7 base
mariadb-test.x86_64 1:5.5.68-1.el7 base
卸载mariadb,按Y确认
rpm -qa|grep mariadb
yum remove mariadb-l*
2安装mysql社区版
地址:https://dev.mysql.com/downloads/
![image-20230904161658664](/Users/liuzhiyuan/Library/Application Support/typora-user-images/image-20230904161658664.png)
![image-20230904161733967](/Users/liuzhiyuan/Library/Application Support/typora-user-images/image-20230904161733967.png)
点击download,可以下载到电脑,然后上传到服务器,也可以右键红色框选择复制链接。然后直接在服务器开始下载
3解压mysql安装包到制定路径
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar -C /opt/mysql/*
1:依次安装下面的安装包:rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
如果报出如下错误,是mariadb没卸载,参照第一步
warning: mysql-community-common-5.7.35-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.35-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
2:rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
3:rpm -ivh mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
4:rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
5:rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
若是这一步报下面的错误,需要安装libaio依赖,再次执行这一步
warning: mysql-community-server-5.7.35-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64
安装libaio依赖,按Y确认: yum install libaio
4.配置mysql
vi /etc/my.cnf
查看/etc/my.cnf文件,查看datadir指向的文件夹下面是否为空,不为空则清空此文件夹。一般是指向/var/lib/mysql。
1:初始化数据库: mysqld --initialize --user=root
2:打开/var/log/mysqld.log,查看root的初始密码。把密码复制下来。
cat /var/log/mysqld.log
5.启动数据库
systemctl start mysqld
启动的时候报错,因为数据库的文件夹权限不够。赋权限即可。然后再次运行数据库。
命令:chmod -R 777 /var/lib/mysql
报错信息:Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
登录mysql:mysql -uroot -p 输入刚才保存的随机密码
修改密码:set password = password("123456");
设置所有IP可以链接:update mysql.user set host='%' where user='root';
刷新数据库:flush privileges;
标签:x86,mysql,64,版本,linux,mariadb,rpm,el7
From: https://www.cnblogs.com/liu-note/p/17814617.html