CentOS 7 安装 MySql

一、安装MySql

1
2
3
[root@centos]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@centos]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@centos]# yum install mysql-server

二、启动MySql

1
[root@centos]# systemctl start mysqld

三、登陆MySql

1
[root@centos]# mysql -u root -p

注:默认安装的MySql密码为空,直接回车即可登陆

四、修改MySql登陆密码

1
2
3
4
5
6
[root@centos]# mysql -u root -p
Enter password:

mysql> use mysql
mysql> update user set password=password('test') where user = 'root';
mysql> flush privileges;

五、配置MySql允许远程访问

1
2
3
4
5
[root@centos]# mysql -u root -p
Enter password:

mysql> grant all privileges on *.* to root@'%' identified by 'test';
mysql> flush privileges;