CentOS6.8 安裝配置Mysql


1、下載mysql的repo源

  wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2、安裝mysql-community-release-el7-5.noarch.rpm包

  rpm -ivh mysql-community-release-el7-5.noarch.rpm

  安裝這個包后,會獲得兩個mysql的yum repo源: 

  /etc/yum.repos.d/mysql-community.repo和 /etc/yum.repos.d/mysql-community-source.repo。

   安裝  yum install mysql-server

若報錯:

 

 解決辦法:1、vi mysql-community.repo

       2、找到mysql-56-community,enable置為0 enable=0;

          並重新安裝    yum install mysql-server

 3、字符集配置(/etc/my.cnf)

  在[mysqld]節點下添加

    default-character-set=utf8

    character-set-server=utf8

  保存退出:wq

4、中文亂碼配置,windos下配置my.ini

  (1)在5.1版本時,my.ini內【mysql】和【mysqld】中都寫:

    default-character-set=utf8

  (2)而在5.5版本,【mysql】內這么寫,【mysqld】內不能,而是:

    character-set-server=utf8

5、自啟動配置

  (1)執行chkconfig mysqld on

  (2)執行chkconfig --list mysqld(查看2-5位為on,即為ok)

6、防火牆配置

  (1)sudo vi /etc/sysconfig/iptables

  (2)-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT   添加到里面

  (3)重啟防火牆 service iptables restart

7、重啟mysql  service mysqld restart

8、用戶配置

  (1)查看當前用戶 select user,host,password from mysql.user;

  (2)刪除匿名用戶 delete from mysql.user where user="";

  (3)為root設置密碼  set password for root@localhost=password('yourpassword');

  (4)添加用戶  insert into mysql.user(host,user,password) values('localhost','yourUserName',password('yourpassword'));

  (5)創建庫  create database `databaseName` default character set utf8 collate utf8_general_ci;

  (6)本地用戶賦予所有的權限  

    grant all privileges on databaseName.* to yourusername@localhost identified by `yourpassword`;

    給賬號開通外網所有的權限。

    grant all privileges on databaseName.* to yourusername@'%' identified by `yourpassword`;

    結合實際情況決定開通什么權限!!!

    grant select,insert,update on databaseName.* to yourusername@'192.168.10.205' identified by `yourpassword`;

  (7)使操作生效 flush privileges;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM