歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

Centos 安裝mysql5.7,centos安裝mysql5.7

Centos 安裝mysql5.7,centos安裝mysql5.7


Centos 安裝mysql5.7,centos安裝mysql5.7


1. 從mysql的官網下載mysql57-community-release-el6-8.noarch.rpm

2. 安裝第一步下載的rpm

rpm -ivh mysql57-community-release-el6-8.noarch.rpm

3. 安裝完成之後,我們發現在/etc/yum.repos.d目錄下新增了兩個文件:其中第二文件記錄了mysql的源信息。

1 mysql-community.repo
2 mysql-community-source.repo

4. 查看可用的mysql安裝源

 yum repolist enabled | grep mysql
 
1 mysql-connectors-community  MySQL Connectors Community                       21
2 mysql-tools-community       MySQL Tools Community                            24
3 mysql57-community           MySQL 5.7 Community Server                       56

5. 使用yum安裝mysql(自動解決依賴問題,並安裝了其他相關包)(如果需要保存下載的包,則修改/etc/yum.conf,將 

   keepcache=0 改為keepcache=1)

yum install mysql-community-server

Installing:

 mysql-community-libs            i686     5.7.13-1.el6            mysql57-community     2.0 M

     replacing  mysql-libs.i686 5.1.73-3.el6_5

 mysql-community-libs-compat     i686     5.7.13-1.el6            mysql57-community     1.6 M

     replacing  mysql-libs.i686 5.1.73-3.el6_5

 mysql-community-server          i686     5.7.13-1.el6            mysql57-community     140 M

Installing for dependencies:

 mysql-community-client          i686     5.7.13-1.el6            mysql57-community      22 M

 mysql-community-common          i686     5.7.13-1.el6            mysql57-community     327 k

Updating for dependencies:

 postfix                         i686     2:2.6.6-6.el6_7.1       base                  2.0 M


Transaction Summary

==============================================================================================

Install       5 Package(s)

Upgrade       1 Package(s)

6 .安裝完成之後,查看mysql服務的狀態

 sudo service mysqld status
 
 mysqld (pid  26422) is running...

7. 停止mysql服務,然後以安全模式啟動mysql。

1 sudo service mysql stop
2 sudo mysqld_safe --skip-grant-tables --skip-networking &

8. 無密碼登陸root, 設置root密碼

1 mysql -u root
2 
3 
4 mysql> use mysql;
5 mysql>update user set authentication_string=password('12345678') where user='root';
6 mysql> flush privileges;

9. 修改字符集為utf8

vim /etc/my.cnf

在[mysqld]部分添加:
character-set-server=utf8

在文件末尾新增[client]段,在[client]段添加:
default-character-set=utf8

10. 查看字符

show variables like "%character%";

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

 

 

 

 

http://xxxxxx/Linuxjc/1135723.html TechArticle

Copyright © Linux教程網 All Rights Reserved