温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos7 系统安装MySQL具体方法

发布时间:2020-05-06 17:39:21 来源:亿速云 阅读:195 作者:三月 栏目:数据库

本文主要给大家简单讲讲centos7 系统安装MySQL具体方法,相关专业术语大家可以上网查查或者找一些相关书籍补充一下,这里就不涉猎了,我们就直奔主题吧,希望centos7 系统安装MySQL具体方法这篇文章可以给大家带来一些实际帮助。

本示例为centos7版本:mysql为mysql-5.5.56.tar.gz

1.云服务器上的卸载原有数据库

rpm -qa | grep mariadb ###查询本机有没有默认的mysql,centos7版本数据库为mariadb

rpm -e --nodeps  ###有的话卸载掉

2.下载源码包

https://www.mysql.com/  ###下载地址

下载好后传到云服务器

3.安装依赖包

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

4.创建用户

groupadd mysql

useradd -M -s /sbin/nologin mysql -g mysql

5.解压,源码编译安装

tar zvxf mysql-5.5.56.tar.gz -C /usr/local/

cd /usr/local/mysql-5.5.56/

编译:cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLL

ATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all

安装:make

make install

6.对数据库目录进行授权

centos7 系统安装MySQL具体方法

chmown -R mysql:mysql /usr/local/mysql

7.建立配置文件

拷贝mysql源码目录中的support-files文件夹下到/etc/mycnf

cp support-files/my-medium.cnf /etc/my.cnf

8.初始化数据库

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/loca

l/mysql/data/

9.设置环境变量

export PATH=$PATH:/usr/local/mysql/bin

10.添加系统服务

cp -P support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod a+x /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

11.启动数据库:

service mysqld start

service mysqld status

netstat -anpt | grep mysqld

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      14245/mysqld

12.访问数据库(默认没有密码)

mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.56-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

centos7 系统安装MySQL具体方法就先给大家讲到这里,对于其它相关问题大家想要了解的可以持续关注我们的行业资讯。我们的板块内容每天都会捕捉一些行业新闻及专业知识分享给大家的。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI