1. 程式人生 > >Centos安裝mysql5.6.33

Centos安裝mysql5.6.33

信息 rip oot 重命名 ase color 服務器 ogg tro

下載安裝包

  百度網盤地址:

    鏈接:https://pan.baidu.com/s/15xaHIqvjggS_rFP_jL-BVA

    提取碼:mh48

上傳到服務器

  mkdir mysql #在/usr/local/目錄下創建mysql文件夾

  使用rz命令上傳到/usr/local/mysql/目錄下

  tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz #解壓

  mv mysql-5.6.33-linux-glibc2.5-x86_64 mysql #重命名文件夾為mysql

安裝mysql

groupadd mysql
#創建mysql用戶組
useradd -g mysql mysql  #創建mysql用戶並添加到mysql用戶組
cp mysql/support-files/my-default.cnf /etc/my.cnf   #創建my.cnf文件
vim /etc/my.cnf  #編輯my.cnf文件

下面是我的my.cnf文件內容
  
我的配置如下
[mysqld]
init_connect=‘SET collation_connection = utf8_unicode_ci‘
init_connect=‘SET NAMES utf8‘
character-set-server=utf8
collation
-server=utf8_unicode_ci skip-character-set-client-handshake # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir
=/usr/local/mysql/ datadir = /usr/local/mysql/data log-error = /usr/local/mysql/data/error.log pid-file = /usr/local/mysql/data/mysql.pid user = mysql tmpdir = /tmp #datadir = ..... port =3306 # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M [client] default-character-set=utf8 [mysql] default-character-set=utf8
cd /usr/local/mysql/  #進入mysql目錄
chown -R mysql:mysql ./    #修改當前目錄擁有者為mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/   #安裝數據庫
chown -R mysql:mysql data  #修改當前data目錄的擁有者為mysql用戶

配置mysql

chown 777 /etc/my.cnf  #給my.cnf最大權限
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld  #復制啟動腳本到資源目錄
chmod +x /etc/rc.d/init.d/mysqld  #增加mysql服務控制腳本執行權限
chkconfig --add mysqld  #將mysqld服務加到系統服務中
chkconfig --list mysqld  #檢查mysqld服務是否已經生效

至此安裝完成,使用 service mysqld start 啟動mysql
vim ~/.bash_profile  #將mysql的bin目錄加入PATH環境變量,編輯 ~/.bash_profile文件

在文件最後添加如下信息:export PATH=$PATH:/usr/local/mysql/bin

source ~/.bash_profile
#刷新一下
之後登陸mysql  mysql -uroot -p,默認是沒有密碼的,之後修改密碼為root update user set password=password(‘root‘) where user=‘root‘ and host=‘localhost‘;

flush privileges;  #
之後允許遠程連接遠程連接的用戶名和密碼我設置為root

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;


 
 

 

  

Centos安裝mysql5.6.33