centos7安装mysql
centos7安装mysql
weidedong 发表于1年前
centos7安装mysql
  • 发表于 1年前
  • 阅读 42
  • 收藏 3
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

1.配置源

# wget http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
# rpm -Uvh  mysql57-community-release-el7-9.noarch.rpm  #安装源,下载的那个rpm
警告:mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql57-community-release-el7-9  ################################# [100%]
# ls /etc/yum.re* | grep mysql   #查看安装的源
mysql-community.repo
mysql-community-source.repo
[root@localhost yum.repos.d]# yum repolist all | grep mysql  #查看mysql的源
mysql-connectors-community/x86_64 MySQL Connectors Community         启用:    21
mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用
mysql-tools-community/x86_64      MySQL Tools Community              启用:    36
mysql-tools-community-source      MySQL Tools Community - Source     禁用
mysql-tools-preview/x86_64        MySQL Tools Preview                禁用
mysql-tools-preview-source        MySQL Tools Preview - Source       禁用
mysql55-community/x86_64          MySQL 5.5 Community Server         禁用
mysql55-community-source          MySQL 5.5 Community Server - Sourc 禁用
mysql56-community/x86_64          MySQL 5.6 Community Server         禁用
mysql56-community-source          MySQL 5.6 Community Server - Sourc 禁用
mysql57-community/x86_64          MySQL 5.7 Community Server         启用:   128
mysql57-community-source          MySQL 5.7 Community Server - Sourc 禁用
mysql80-community/x86_64          MySQL 8.0 Community Server         禁用
mysql80-community-source          MySQL 8.0 Community Server - Sourc 禁用

2.安装

# yum install -y  mysql-community-server  #执行完就坐等好了,是不是很简单呢

3.启动mysql

# systemctl start mysqld
[root@localhost yum.repos.d]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 二 2016-10-04 22:55:33 CST; 5s ago

4.修改密码

# grep 'temporary password' /var/log/mysqld.log   #查看初始密码
2016-10-04T14:55:29.376951Z 1 [Note] A temporary password is generated for root@localhost: hIkatKeYQ8*9
# mysql -uroot -p     #输入初始密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';   #修改密码
Query OK, 0 rows affected (0.02 sec)

5.开放远程连接权限

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>  select host,user from user;
+-----------+-----------+
| host      | user      |
+-----------+-----------+
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
2 rows in set (0.01 sec)
mysql>  Grant all privileges on *.* to 'root'@'%' identified by 'MyNewPass4!' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>  select host,user from user;
+-----------+-----------+
| host      | user      |
+-----------+-----------+
| %         | root      |
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
3 rows in set (0.00 sec)

使用Sequel Pro测试连接mysql,下载地址http://www.sequelpro.com/download/

输入图片说明

注:如果想修改默认配置,如db文件目录,请修改文件/etc/my.cnf

共有 人打赏支持
粉丝 1
博文 33
码字总数 16571
×
weidedong
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: