centos7 如何安装MySQL --详细安装
2017-06-13 16:56
363 查看
本示例为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.对数据库目录进行授权
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>
本文档只写到怎么安装数据库,下次文档会写如何使用数据库
希望我的文档能帮助更多的人!——帅小欣
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.对数据库目录进行授权
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环境安装下安装Apache+php7+mysql详细步骤
- CentOS7安装后MySQL5.6如何配置MySQL5.6呢?
- Centos7安装mysql详细命令
- Centos7 的Docker上如何安装MySQL
- 【超详细】如何部署javaWeb项目流程 阿里云linux-ubuntu下mysql+tomcat+jdk安装
- CentOs7 下安装LAMP环境(超级详细) 之 mysql
- centos7下安装mysql5.6的详细步骤,以及所遇到的错误解答
- 如何在腾讯云centos7中安装mysql,Tomcat超全详细
- CentOS7安装MySQL5.6详细步骤
- Centos7 离线安装mysql 5.6详细步骤
- Centos7安装mysql5.6详细教程
- Windows最新版Apache2、PHP5、MySQL6、PHPMyadmin、ZendOptimizer安装详细过程
- 详细说明mantis在windowsXP下的安装过程(IIS+MYSQL+PHP)
- MySQL服务器安装完之后如何调节性能
- 讲解MySQL服务器安装之后如何调节性能
- 教你如何在Linux/Unix平台安装MySQL
- 在Linux下安装mysql详细步骤
- Mysql详细安装
- MySQL服务器安装完之后如何调节性能
- 讲解MySQL服务器安装之后如何调节性能