下载MySQL
#两种方法 1、直接进官网下载, 2、把下载号的安装包托到虚拟机 #安装包托进去以后,发现进度条不动,虚拟机提示 [root@pdun ~]# rz -E -bash: rz: command not found 说明没有安装 lrzsz ,这时,输入命令 yum -y install lrzsz
安装
1.下载 [root@web01 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz 2.解压 [root@oldboy ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz 3.移动到安装目录 [root@oldboy ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.40 4.软链接 [root@oldboy ~]# ln -s /usr/local/mysql-5.6.40 /usr/local/mysql 5.进入MySQL程序目录 [root@oldboy ~]# cd /usr/local/mysql 再cd cd support-files/ 6.拷贝配置文件 [root@oldboy /usr/local/mysql/support-files]# cp my-default.cnf /etc/my.cnf 7.拷贝启动脚本 [root@oldboy /usr/local/mysql/support-files]# cp mysql.server /etc/init.d/mysqld 8.创建mysql用户 [root@oldboy /usr/local/mysql/support-files]# useradd mysql -s /sbin/nologin -M 9.进入mysql初始化目录 [root@oldboy /usr/local/mysql]# cd ../scripts/ 10.安装依赖包 [root@oldboy /usr/local/mysql/scripts]# yum install -y libaio-devel 11.初始化mysql [root@oldboy /usr/local/mysql/scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 12.添加环境变量 [root@oldboy /usr/local/mysql/scripts]# vi /etc/profile export PATH="/usr/local/mysql/bin:$PATH" 13.加载环境变量 [root@oldboy /usr/local/mysql/scripts]# source /etc/profile 14.启停MySQL 启动:[root@oldboy /usr/local/mysql/scripts]# /etc/init.d/mysqld start 停止:[root@oldboy /usr/local/mysql/scripts]# /etc/init.d/mysqld stop 15.连接MySQL [root@oldboy /usr/local/mysql/scripts]# mysql 16.设置MySQL密码 [root@oldboy /usr/local/mysql/scripts]# mysqladmin -uroot -p password '123' 17.修改密码 [root@oldboy /usr/local/mysql/scripts]# mysqladmin -uroot -p123 password '1' [root@oldboy /usr/local/mysql/scripts]# mysql -uroot -p1