1.下载YUM库
shell > wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安装YUM库
shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3.安装数据库
shell > yum install -y mysql-community-server
4.启动MySQL服务
shell > systemctl start mysqld.service
5.默认空密码
shell > mysql -uroot -p
输入密码后提示:ERROR 1045 (28000): access denied for user 'root'@'localhost' (using passWord: NO)6.开启mysql安全模式(重要!这里跟百度出来其他开启安全模式方法不一样)
修改my.cnf,添加skip-grant-tables和skip-networking
输入:vi /etc/my.cnf
[mysqld]
skip-grant-tables
skip-networking
重启mysql 然后输入: mysql -uroot mysql 此时即可登录mysql
然后:update mysql.user set authentication_string=password("root123") where user="root" and Host="localhost";
flush PRivileges;
quit;
重启mysql后添加远程登录用户(登入Mysql):
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123' WITH GRANT OPTION;
此时提示:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
意思是要修改密码,原来忘记修改my.cnf 退出安全模式
输入:vi /etc/my.cnf 删除
skip-grant-tables
skip-networking
修改密码时 如遇到提示: You must reset your password using ALTER USER statement before executing this statement.执行下列操作:set global validate_password_policy=0;
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=3;
set global validate_password_special_char_count=0;set global validate_password_length=3;
然后更改密码即可
新闻热点
疑难解答