欢迎光临
我的个人博客

centos7 安装mysql

1. 下载mysql的repo源
yum install wget -y
cd /etc/yum.repos.d/
wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm

2. 安装mysql57-community-release-el7-11.noarch.rpm包
sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm

3. 安装mysql
sudo yum install mysql-server -y

4.重置密码与授权
service mysqld start
或者
/etc/init.d/mysqld start

5.获取mysql默认密码并登录

grep 'temporary password' /var/log/mysqld.log

mysql -u root -p

set password for 'root'@'localhost'=password('1qaz@WSX');

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY '1qaz@WSX' WITH GRANT OPTION;

Create database gogs;

alter database gogs character set utf8mb4;

flush privileges;

exit

5.设置不区分大小写
vi /etc/my.cnf
在[mysqld]节点下增加
lower_case_table_names = 1
:wq退出

6.重启服务
service mysqld restart

7.测试登陆
mysql -u root -p

8.输入密码查看是否成功

注:如果重启报错 可能是权限问题,需要到mysql安装目录授权
去mysql安装目录/var/lib/mysql/mysql 分别执行: chown mysql * chgrp mysql * chmod ug+rwx *

转载请标明来源:ibear » centos7 安装mysql

分享到:更多 ()

Where there is a will there is a way

BladeX企业级开发平台