安装mysql

Posted fanningwen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装mysql相关的知识,希望对你有一定的参考价值。

下载并安装mysql官方的Yum Repository

[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

使用上面的命令直接安装Yum Repository

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

安装MySQL

root@localhost ~]# yum -y install mysql-community-server

启动MySQL

[root@localhost ~]# systemctl start mysqld

查看MySQL运行状态

systemctl status mysqld

停止mysql

systemctl stop mysqld

查看root账号密码

[root@localhost ~]# grep "password" /var/log/mysqld.log

2018-12-10T08:02:37.585544Z 1 [Note] A temporary password is generated for [email protected]: i6i/pdTUBbkq

进入mysql

mysql -u root -p

修改mysql密码

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new password‘;(直接设置密码不能过于简单)

 

可通过如下命令查看完整的初始密码规则

mysql>show variables like ‘validate_password‘;

可通过如下命令修改

mysql> set global validate_password_policy=0;

 

 

 

配置权限

 

#任何主机
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

 

#指定主机
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘jack‘@’10.10.50.127’ IDENTIFIED BY ‘654321‘ WITH GRANT OPTION;

 

# 然后刷新权限
mysql>flush privileges;

修改mysql数据库总的user表使相的用户能从某一主机登录

mysql>use mysql;
mysql>update user set host = ‘%‘ where user = ‘root‘;
mysql>select host, user from user;


查看mysql的字符集

mysql>show variables like ‘character_set%‘;

技术分享图片

 

from  https://blog.csdn.net/baidu_32872293/article/details/80557668

 









以上是关于安装mysql的主要内容,如果未能解决你的问题,请参考以下文章

mysql如何安装?

MySQL安装Error 1045

mysql如何安装

MySQL 5.7怎样安装

windows怎么安装mysql

windows怎么安装mysql