centos安装
下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装mysql源
shell> yum localinstall mysql57-community-release-el7-11.noarch.rpm
安装MySQL
shell> yum install mysql-community-server
启动MySQL服务
shell> systemctl start mysqld
设置开机启动
shell> systemctl enable mysqld
shell> systemctl daemon-reload
修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
grep 'temporary password' /var/log/mysqld.log
通过下面的方式找到root默认密码,然后登录mysql进行修改
shell> mysql -u root -p --输入查找的密码
更改本地密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'M$Fa!SN5';
更改远程密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '*****' WITH GRANT OPTION;
mysql> create user '用户名'@'%' identified by '密码';
FLUSH PRIVILEGES;刷新数据库
设置开启远程访问
打开mysql配置文件vi /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1注销
debian
wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
dpkg -i mysql-apt-config_0.8.13-1_all.deb
apt update
apt install mysql-server
安装完成后,其他设置相同