Centos安裝mysql5.6.33

下載安裝包

  百度網盤地址:mysql

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

    提取碼:mh48
sql

上傳到服務器

  mkdir mysql   #在/usr/local/目錄下建立mysql文件夾數據庫

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

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

  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;
相關文章
相關標籤/搜索