1、安装mysql
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server -y
2、重启mysql
service mysqld restart
不出意外,这时候就可以不用账号密码进入mysql
3、设置root密码
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
这时候可以根据自己设置的账户密码本地登陆mysql了
4、解除远程连接限制
默认mysql是不允许远程主机连接的,会报mysql is not allowed to connect to this MySQL server
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
此时就可以使用myuser用户,mypassword密码远程登陆mysql服务器了