我这里用的是 CentOS-6.5-x86_64 版本的系统html
下载版本:mysql
# 下载mysql安装包,若是已下载请忽略此步 $ wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz # 解压 $ tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz -C /usr/local $ cd /usr/local $ mv mysql-5.6.33-linux-glibc2.5-x86_64 ./mysql
#添加用户组 groupadd mysql #添加用户mysql 到用户组mysql useradd -g mysql mysql
$ cd /usr/local/mysql/ #建立 数据文件所在目录 $ mkdir ./data/mysql #把MySQL 更改所属用户和组 $ chown -R mysql:mysql ./ #初始化 MySQL $ ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql #添加启动项 $ cp support-files/mysql.server /etc/init.d/mysqld #赋予权限 $ chmod 755 /etc/init.d/mysqld $ cp support-files/my-default.cnf /etc/my.cnf #修改启动脚本 $ vi /etc/init.d/mysqld #修改项: $ basedir=/usr/local/mysql/ $ datadir=/usr/local/mysql/data/mysql #开机启动脚本 $ chkconfig --add mysqld $ chkconfig --level 35 mysqld on #启动服务 $ service mysqld start #启动mysql service mysqld start #关闭mysql service mysqld stop #查看运行状态 service mysqld status #测试链接 $ ./mysql/bin/mysql -u root
#加入环境变量,编辑 /etc/profile,这样能够在任何地方用mysql命令了 $ vi /etc/profile #给文档最后添加 export PATH=$PATH:/usr/local/mysql//bin #执行wq保存退出。 $ source /etc/profile
$ mysqladmin -u用户名 -p旧密码 password 新密码 #或进入mysql命令行 SET PASSWORD FOR '用户名'@'主机' = PASSWORD(‘密码');
grant all privileges on *.* to 用户名@'%' identified by '密码' with grant option;
$ netstat -anpt | grep mysql
$ ps -elf | grep mysqld
本文来源参考于:http://www.javashuo.com/article/p-rgjcynke-bg.htmllinux