下载Mysql源安装包
:::success wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm :::
yum安装mysql源
:::success yum localinstall mysql57-community-release-el7-8.noarch.rpm -y :::
检查mysql源是否安装成功
:::success yum repolist enabled | grep “mysql.-community.“ :::
yum安装Mysql
:::success yum install mysql-community-server -y :::
启动Mysql服务
:::success systemctl start mysqld :::
并添加开机启动
:::success
systemctl enable mysqld systemctl daemon-reload
:::
或者
:::success
1 vim /etc/rc.local
2 添加service mysqld start
:::
查看Mysql状态
:::success systemctl status mysqld ::: 查看默认的mysql密码 此时Mysql安装完成!!!
修改密码
:::success
查看默认的mysql密码
vi /var/log/mysqld.log
设置密码等级(仅仅自己使用)
set global validate_password_policy=LOW;
set global validate_password_length=6;
set password for ‘root’@’localhost’=password(‘123456’);
:::
登录mysql
:::success mysql -uroot -p 回车 密码: =>g6hj.Nx4e (上面查看的原始密码) :::
添加远程登陆的用户权限
:::success mysql5.7:
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
:::
:::success
mysql8:
use mysql;select host, user, authentication_string, plugin from user;
update user set host=’%’ where user=’root’;FLUSH PRIVILEGES;:::
修改mysql字符编码
:::success
vi /etc/my.cnf
添加
character_set_server=utf8
init_connect=’SET NAMES utf8’ :::
重启Mysql
:::success
systemctl stop mysqld
systemctl start mysqld
:::