linux mysql-5.6.26 安裝

下載地址

ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gzmysql

解壓

tar -xzf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

注:安裝目錄須要設置到解壓目錄,不然報如下錯誤linux

FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

orsql

FATAL ERROR: Could not find my-default.cnf

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

 將解壓的目錄放到/usr/local下改成mysql或添加軟鏈接vim

mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql

or安全

ln -s  /www/mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql

增長mysql用戶和組

groupadd mysql
useradd -r -g mysql mysql

修改mysql目錄及子文件屬主和屬組bash

chown -R mysql:mysql mysql

進入mysql目錄並安裝

cd mysql
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql

安裝過程可能缺乏某些文件,通常用 yum install -y xxx 按需安裝便可.socket

實現使用 service mysqll (start|status|stop) 命令操做mysql.spa

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

錯誤:code

[root@localhost mysql]# mysql
-bash: mysql: command not found

解決:配置環境變量,把 export PATH=$PATH:/usr/local/mysql/bin添加到 /etc/profile中, source /etc/profile從新加載環境變量, service mysql start啓動mysql服務。server

錯誤:

[root@localhost mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解決:

mysql --socket=/var/lib/mysql/mysql.sock
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

啓動成功

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.26 |
+-----------+
1 row in set (0.00 sec)

成功後可能須要往mysql的user表增長新帳號

錯誤:指定了嚴格模式,爲了安全,嚴格模式禁止經過insert 這種形式直接修改mysql庫中的user表進行添加新用戶

1364 - Field 'ssl_cipher' doesn't have a default value

解決:

vim /usr/local/mysql/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
改成
sql_mode=NO_ENGINE_SUBSTITUTION
相關文章
相關標籤/搜索