1.msyql下载
mysql-5.6.33 通用版,linux64位,官方下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads。
也可以通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
百度云盘地址:链接:https://pan.baidu.com/s/1ymI5QNto3-JRzLNbQQfBxQ 提取码:uxf2
2.创建mysql用户
useradd mysqlpasswd mysql
3.解压下载包
tar -xvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.33-linux-glibc2.5-x86_64 /usr/localcd /usr/localmv mysql-5.6.33-linux-glibc2.5-x86_64 mysql chown -R mysql.mysql mysql
4.配置环境变量
保证mysql命令可以全局使用
vi /etc/profile
在最后添加:export PATH=$PATH:/usr/local/mysql/bin
5.创建数据存储目录
df -h查看最大的磁盘,例如/hdd最大
mkdir /hdd/mysql 用于存储数据,确保目录mysql可以访问。
6.安装mysql
切换到mysql用户,cd /usr/local
./scripts/mysql_install_db --user=mysql --datadir=/hdd/mysql
7.配置mysqld到service启动
root用户/usr/local目录下,cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vi /etc/init.d/mysqld
修改:basedir=/usr/local/mysql/ datadir=/hdd/mysql
8.更改配置文件位置
root用户/usr/local目录下,cp support-files/my-default.cnf /etc/my.cnf
9.启动服务
用mysql用户,启动mysql 执行:service mysqld start
service mysqld stop 关闭mysql
service mysqld status 查看mysql状态
10.mysql授权
连接mysql ,输入mysql -uroot
set password = password('123456'); # 修改root初始密码
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; # 远程连接授权
11.常见问题
问题: FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:Data::Dumper
解决方法:yum -y install autoconf
问题:Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法:yum install libaio* -y
问题:bash: service: command not found
解决方法:yum install initscripts -y