centos mysql5.7 安装及初始化配置
程序员文章站
2022-04-14 13:44:26
...
1、配置YUM源
在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
1、下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2、安装mysql源
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
2、安装MySQL
shell> yum install mysql-community-server
3、启动MySQL服务
shell> systemctl start mysqld
4、配置MySQL
1、我这里想把密码设置成简单的root,如果不愿意的直接跳过这一步就好了
1-1、修改mysql配置文件
shell> vi /etc/my.conf (need root)
1-2、在my.conf [mysqld]的文末加入
validate_password = off # 关闭密码策略
character_set_server=utf8 # 编码设置
init_connect='SET NAMES utf8' # 编码设置
lower_case_table_names=1 # 在SQL查询中忽略表的大小写
1-3、保存退出
1-4、重启mysql
shell> systemctl restart mysqld
1、获取初始密码:
shell> grep 'temporary password' /var/log/mysqld.log
2、登录数据库,输入密码
mysql> mysql -u root -p
3、更改密码
mysql> set password for 'root'@'localhost'=password('你的密码');
4、接下来配置mysql服务,让其支撑远程访问
mysql> grant all privileges on *.* to aaa@qq.com'%' identified by 'root';
5、刷新
mysql> flush privileges;
6、查看数据库的编码 (如果上面设置了编码,这里显示为utf-8)
mysql> show variables like "%character%";
6、退出
mysql> exit;
7、重启mysql
shell> systemctl restart mysqld