下載地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloadshtml
這裏我選擇5.6.41 Linux-Generic,以下圖:
再選擇Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive包,根據系統選擇32或64位,以下圖:
點擊下載mysql
root用戶登陸,上傳安裝包到服務器
cd /opt
rz
解壓
tar -xvf mysql-5.6.41-linux-glibc2.12-x86_64.tar
複製解壓後的mysql目錄
cd mysql-5.6.41-linux-glibc2.12-x86_64
linux
mkdir /usr/loacl/mysql
sql
cp -r ./* /usr/local/mysql
bash
添加用戶組
groupadd mysql
添加用戶mysql到用戶組
useradd -g mysql mysql
服務器
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp support-files/mysql.server /etc/init.d/mysql
cp support-files/my-default.cnf /etc/my.cnf
socket
vi /etc/my.cnf
測試
修改:spa
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
server_id=1
socket=/tmp/mysql.sock3d
添加:
character_set_server=utf8
加入環境變量,編輯 /etc/profile,這樣能夠在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
啓動mysql
service mysql start
修改root密碼
mysqladmin -u root password '123456'
測試鏈接
mysql -u root -p
關閉mysql
service mysql stop
查看運行狀態
service mysql status
開機自啓動配置
chkconfig --add mysql
chkconfig --list
chkconfig --level 345 mysql on
容許全部外部連接訪問
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; FLUSH PRIVILEGES;
安裝時的一些錯誤
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 沒有那個文件或目錄
解決: yum -y install perl perl-devel
Installing MySQL system tables…./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決:yum -y install libaio-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解決:yum -y install numactl
啓動時一些錯誤
Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
解決:關閉selinux 在/etc/selinux/config下永久關閉,臨時關閉使用setenforce 0命令。