1、下载MySql的rpm包
[root@VM_39_157_centos ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@VM_39_157_centos ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
2、更新yum
[root@VM_39_157_centos ~]# yum update
3、使用yum安装mysql-server
[root@VM_39_157_centos ~]# yum install mysql-server
3、赋权限
[root@VM_39_157_centos ~]# chown mysql:mysql -R /var/lib/mysql
4、初始化
[root@VM_39_157_centos ~]# mysqld --initialize
5、启动服务:
[root@VM_39_157_centos ~]# systemctl start mysqld
6、查看服务状态:
[root@VM_39_157_centos ~]# systemctl status mysqld
7、设置开机启动
[root@VM_39_157_centos ~]# systemctl enable mysqld
8、设置密码
[root@VM_39_157_centos ~]# mysqladmin -uroot password '123'
9、设置免密登录
mysql 配置文件目录:/etc/my.cnf
root 密码为空的时候配置文件中下面这句:
|
10、设置root用户可访问,后期连接上之后可以重新设置
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;