centos7 安装msyql5.7
1. 在mysql官网下载mysql mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
2. 解压 tar -xvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
3. 添加mysql用户和组,然后安装mysql并启动,初始密码由/root/.mysql_secret保存,使用的命令如下:
groupadd mysql
useradd mysql -g mysql
4.cd /usr/local/mysql/bin
./mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data
cd /usr/local/mysql/support-files
./mysql.server start
- 使用初始密码登录mysql,并修改密码,同时设置root可以远程连接
命令如下:
cat /root/.mysql_secret
cd /usr/local/mysql/bin
./mysql -u root -p
set password =password(‘新密码’);
GRANT ALL PRIVILEGES ON . TO root@”%” IDENTIFIED BY “1新密码”;
- sr将mysql设置为开机自启动,并添加软连接
命令如下:
cd /usr/local/mysql/support-files/
cp mysql.server /etc/init.d
cd /etc/init.d
mv mysql.server mysqld
cd /usr/bin
ln -s /usr/local/mysql/bin/mysql mysql