windows
windows下可以安装社区版本,界面版,安装选择custom,选择需要的版本,一般选择server版。不过我的win10不清楚为什么没有通过,好像是需要什么visual 2019插件,我电脑没有,后面就没安装了。
linux
linux下安装linux,使用的是阿里云服务器,yum install mysql就可以安装,之前最好yum -y update一下。
yum -y update
yum list installed | grep mysql
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
yum install mysql-community-server
systemctl list-unit-files | grep mysqld
systemctl enable mysqld
systemctl start mysqld.service systemctl status mysqld.service
修改密码
mysql -u root
mysql> use mysql;
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yyyyyy’)
update user set password=password('yyyyyy') where user='root';
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yyyyyy');
mysql从5.7后 把password改为authentication_string
update user set authentication_string=password("yyyyyy") where user="root";
mysql8之后只能用下面的语法修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '!Password1';
flush privileges
alter user 'root'@'localhost' identified by 'yyyyyy';
远程登录
设置远程访问root权限
这里的密码跟mysql -u root -p的密码可以不一样。
mysql -u root -p
show databases;
use mysql;
CREATE USER 'root'@'%' IDENTIFIED BY 'xxxxxx';
GRANT ALL ON *.* TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';
FLUSH PRIVILEGES;
查看端口
show global variables like 'port';
设置安全组端口开放
Navicat 连接
mysql8.0 引入了新特性 caching_sha2_password;这种密码加密方式Navicat 12以下客户端不支持;
Navicat 12以下客户端支持的是mysql_native_password 这种加密方式;
用如下语句查看MySQL当前加密方式
select host,user,plugin from user;
root加密方式为caching_sha2_password
使用命令将他修改成mysql_native_password加密模式:
update user set plugin='mysql_native_password' where user='root';