Home > Operation and Maintenance > CentOS > How to install mysql5.7 on Centos

How to install mysql5.7 on Centos

藏色散人
Release: 2021-06-30 17:11:50
forward
2844 people have browsed it

1. Download mysql

#进入local目录
cd /usr/local/
#下载mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Copy after login

2. Unzip mysql and change the name

tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
mkdir data
Copy after login

3. Add users and groups

groupadd mysql
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql/
Copy after login

4. Installation command

yum -y install libaio-devel
./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
cp -a ./support-files/my-default.cnf /etc/my.cnf
cp -a ./support-files/mysql.server /etc/init.d/mysqld
Copy after login

5. Modify the configuration file

#打开配置目录
vi /etc/my.cnf
#增加目录配置
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
Copy after login

6. Start, modify the root password, and add remote connection user permissions

#修改环境变量配置文件
vi /etc/profile
#增加mysql全局变量,使service mysqld start可以在任意位置使用
export PATH=$PATH:/usr/local/mysql/bin
#即时生效
source /etc/profile
#启动mysql
service mysqld start
Copy after login
#mysql刚安装完毕没有密码进入mysql命令行
mysql -uroot -p
#查询mysql用户
select User, Host, Password FROM mysql.user;
#修改root密码
update mysql.user set password=password('root') where User="root";
#为root添加远程权限
grant all privileges on *.* to 'root'@'%'identified by 'root' with grant option;
#刷新权限
flush privileges;
Copy after login

The above is the detailed content of How to install mysql5.7 on Centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template