安装mysql

2018-06-18 00:27:31来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

本次安装方式采用yum repo,请前往官网下载对应的版本,由于我的虚拟机安装的是centos7,所以选择Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package,详细的安装步骤请参考mysql官网安装手册

当然,还有其他的安装方式,请参考mysql官网下载页面

开始安装

$ cd /usr/local/src
$ wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
$ yum localinstall mysql57-community-release-el7-11.noarch.rpm
$ yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64       MySQL Connectors Community           42
mysql-tools-community/x86_64            MySQL Tools Community                51
mysql57-community/x86_64                MySQL 5.7 Community Server          227
$ yum install mysql-community-server
$ service mysqld start #启动mysql
$ service mysqld status #查看mysql状态,active(running)表示正在运行
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-10-26 10:56:36 CST; 1h 5min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 2062 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 1989 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 2065 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─2065 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Oct 26 10:56:30 localhost.localdomain systemd[1]: Starting MySQL Server...
Oct 26 10:56:36 localhost.localdomain systemd[1]: Started MySQL Server.

$ grep 'temporary password' /var/log/mysqld.log #查看mysql生成的临时密码
2017-10-26T02:56:33.310140Z 1 [Note] A temporary password is generated for root@localhost: LiLd_/uo/5Zr #这个就是root的临时密码
$ mysql -uroot -p #用临时密码登陆
#修改root密码,由于默认开启了密码验证机制,mysql要求密码长度必须8位以上并带有大小写字母和特殊符号
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '%098NJImko';
Query OK, 0 rows affected (0.00 sec)

授权

mysql> GRANT ALL PRIVILEGES ON *.* TO 'web'@'%' IDENTIFIED BY '%678njiMKO' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:(MariaDB)MySQL数据类型详解和存储机制

下一篇:Mysql知识总结