- mysql5.7 安装 yum在线
安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server
systemctl start mysqld
- 修改密码
- 通过此命令找到原始密码
grep 'temporary password' /var/log/mysqld.log
- 通过临时密码登录
mysql -u root -p
输入临时密码
- 设置root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '1qaz@WSX';
3、开启远程
update user set Host='%' where User='root';
grant all privileges on *.* to root@"本地ip" identified by "1qaz@WSX";
flush privileges;
- 配置默认编码为utf8
vi /etc/my.cnf
#添加 [mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
- 重启/设置开机启动
systemctl restart mysqld
systemctl enable mysqld
- 创建用户、数据库
创建用户:
create user 'testuser'@'%' identified by 'Lsort_7788';
创建数据库:
CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
赋予权限:
GRANT ALL ON testdb.* TO 'testuser'@'%' IDENTIFIED BY 'Lsort_7788';
- 导入sql 文件
source /usr/local/test.sql