MySQL安装
rpm、yum、cmake
<1> 官网下载.rpm软件包
# rpm -ivh *.rpm
<2> mysql服务器联网
# yum -y install mysql
<3> 源码安装,官网下载源码包
# cmake -DWITH_BOOST=boost所在目录
# make && make install
源码安装
0.版本匹配:
centos7以下,centos6.6、mysql5.6、boost1.59
centos7以上,centos7.3、mysql5.7、boost1.59,或者mysql-boost-5.7
1.安装依赖包:
# yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc-c++ autoconf automake bison zlib-devel
2.上传或下载软件包(mysql5.6、boost1.59):
挂载USB设备(U盘)
samba共享
wget网络下载
3.创建组及用户
# groupadd mysql
# useradd -r -s /sbin/nologin -g mysql mysql
4.解压、编译、安装、所属
# tar -xzf 软件包 -C /usr/src
# cd /usr/src/软件包目录
# cmake -DWITH_BOOST=boost所在目录
# make && make install
# chown mysql.mysql /usr/local/mysql
注:默认路径为/var/lib/mysql,配置文件/etc/my.cnf
5.初始化、配置文件
# /usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data
# cp /usr/local/mysql/my.cnf /etc/my.cnf覆盖
6.启动服务、管理进程、环境变量
# /usr/local/mysql/bin/mysqld_safe –user=mysql &
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig –add mysqld
# chkconfig mysqld on
# PATH=$PATH:/usr/local/mysql/bin
# echo “export PATH=$PATH:/usr/local/mysql/bin”>>/etc/profile
7.查看漏洞
# mysql -u root -e “select User,Host,Password from mysql.user”
8.安全设置
# /usr/local/mysql/bin/mysql_secure_installation回车、设置密码、一路Y
9.连接数据库,查看数据库和数据表
# mysql -u root -p
输入密码
# show databases;
# use mysql;
# show tables;
# exit
或者
#quit