安装环境,系统是Centos7.5。数据库是:mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz。
1、下载
个人:
链接:https://pan.baidu.com/s/1o2q3XzFG5Ol0jWYlT_8gBQ
提取码:98wy
下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads
下载版本:我这里选择的5.6.33,通用版,linux下64位
也可以直接复制64位的下载地址,通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、解压
#解压 tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz #复制解压后的mysql目录 cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3、添加用户组和用户
#添加用户组 groupadd mysql #添加用户mysql 到用户组mysql useradd -g mysql mysql
4、安装
cd /usr/local/mysql/ mkdir ./data/mysql chown -R 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 #启动服务 service mysqld start #测试连接 ./mysql/bin/mysql -uroot #加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了 export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile #启动mysql service mysqld start #关闭mysql service mysqld stop #查看运行状态 service mysqld status
5、重置root密码
#修改root用户密码
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
#允许远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
#新增用户
CREATE USER 'mysql'@'%' IDENTIFIED BY 'mysql';
#授权数据库
grant all privileges on database.* to 'username'@'%' identified by 'password' with grant option;
转自:https://www.cnblogs.com/bookwed/p/5896619.html