Mysql安装手册
一:获取mysql安装包
1.1,下载mysql安装包:
可以在mysql官网自行下载安装mysql所需的安装包
官网地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloads
1.2,也可以通过我提供的分享链接进行下载,链接如下:
https://pan.baidu.com/s/1oSipm_OnY4pvp7BHVqttmA
二:安装mysql
2,1,将下载好的软件包上传到系统
安装依赖
执行 yum -y install perl perl-devel 后在初始化数据库即可。 报错如下: FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db: Data::Dumper 在安装以下命令即可 yum install -y perl-Data-Dumper
2,2、解压
[root@localhost ~]# ls anaconda-ks.cfg mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz nginx-1.8.1 nginx-1.8.1.tar.gz #解压 [root@localhost ~]# tar -xf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz [root@localhost ~]# ls anaconda-ks.cfg mysql-5.6.37-linux-glibc2.12-x86_64 mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz nginx-1.8.1 nginx-1.8.1.tar.gz #复制解压后的mysql目录到/usr/local/mysql [root@localhost ~]# cp -r mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql
2.3、添加用户组和用户
创建mysql所使用的用户:
#添加用户组 [root@localhost ~]# groupadd mysql #添加用户mysql 到用户组mysql [root@localhost ~]# useradd -g mysql mysql
2.4、安装
#进入到mysql目录 [root@localhost ~]# cd /usr/local/mysql/ #创建mysql数据存放目录 [root@localhost mysql]# mkdir -p /data/mysq #授予mysql的权限 [root@localhost mysql]# chown -R mysql:mysql ./ [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chmod 755 /etc/init.d/mysqld [root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf cp: overwrite ?.etc/my.cnf?. y [root@localhost mysql]# vi /etc/init.d/mysqld #修改项 basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data/mysql #启动服务 [root@localhost mysql]# service mysqld start Starting MySQL.Logging to '/usr/local/mysql/data/mysql/localhost.localdomain.err'. SUCCESS! [root@localhost mysql]# service mysqld status SUCCESS! MySQL running (63130) [root@localhost mysql]# #测试连接 : [root@localhost mysql]# ./bin/mysql -u root #加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了 [root@localhost mysql]# export PATH=$PATH:/usr/local/mysql/bin/ [root@localhost mysql]# source /etc/profile
三:启动
#启动mysql
service mysqld start
#关闭mysql
service mysqld stop
#查看运行状态
service mysqld status
修改密码 set password for root@localhost = password('123');