CentOS7安装mysql详细步骤
mysql的安装
安装步骤
1、下载 MySQL Yum Repository
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2、添加 MySQL Yum Repository
yum -y install mysql57-community-release-el7-10.noarch.rpm
3、安装mysql社区版
yum -y install mysql-community-server
注意:这一步需要下载190M左右的文件
4、查看mysql服务状态
service mysqld status
5、启动mysql服务
service mysqld start
6、查看mysql服务状态
service mysqld status
7、查看root初始密码
grep “password” /var/log/mysqld.log
8、登录mysql
mysql -uroot -p
9、输入命名
show databases;
显示:You must reset your password using ALTER USER statement before executing this statement.
需要重置密码
10、修改root密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new password’;
密码注意有大小写,例如: Wang!123456
以可以使用以下语句修改密码,效果是一样的:
set password for ‘root’@‘localhost’ = password(‘Li!123456’);
flush privileges;
11、添加新用户
grant all privileges on . to ‘lcx’@’%’ identified by ‘Wang!123456’ with grant option;
火墙打开3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
注意:RPM是Red-Hat Package Manager(RPM软件包管理器)的缩写