如何用“CentOS7 安装Mysql”?
1、
yum安装更方便
yum install wget
2、
新建文件夹
[root@localhost bin]# cd /usr/local/
[root@localhost local]# mkdir mysql
[root@localhost local]# cd mysql
[root@localhost mysql]#
3、
下载并安装MySQL官方的 Yum Repository
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
4、
安装完成后查看版本号:mysql -V
5、
状态是 Active: active (running) ,说明启动成功
启动服务:
service mysqld restart
查看mysql运行状态:
systemctl status mysql.service
停掉mysql服务
service mysqld stop # 或者 systemctl stop mysql.service
6、
MySQL重置密码,先停掉mysql,以安全方式启动
systemctl stop mysql.service
以安全方式启动mysql:
/usr/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 &
然后执行
/usr/bin/mysql -u root mysql
mysql> USER 'root'@'localhost' IDENTIFIED BY '123456'
7、
登陆mysql,试试是否成功:
mysql -u root -p
8、查看MySQL端口号
show variables like 'port';
9、
授权远程连接
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION
10、
开放3306端口:
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=3306/udp --permanent
firewall-cmd --reload
原文地址:https://blog.csdn.net/wuwei13798642/article/details/135709837
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!