1、下载安装包:
下载地址 ==> https://dev.mysql.com/downloads/mysql/
2、解压:
1 tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar 2 cp -r mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
3、添加myslq组和mysql用户:
1 groupadd mysql 2 useradd -r -g mysql -s /bin/false mysql
4、修改目录拥有者为myslq用户:
chown -R mysql:mysql /usr/local/mysql
5、安装:
1 cd /usr/local/mysql 2 ./scripts/mysql_install_db --user=mysql
6、修改目录拥有者为root用户:
chown -R root:root /usr/local/mysql
7、添加mysql到service服务:
1 cp support-files/mysql.server /etc/init.d/mysqld 2 # 加可执行权限 3 chmod +x /etc/init.d/mysql
8、启动:
service mysqld start
9、修改mysql的root用户密码:
/usr/local/mysql/mysqladmin -u root password '密码'
10、mysql客户端放到默认路径:
1 cd /usr/bin 2 ln -s /usr/local/mysql/bin/mysql mysql 3 4 cd /usr/local/bin 5 ln -s /usr/local/mysql/bin/mysql mysql